<!DOCTYPE html>





<html class="theme-next muse use-motion" lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="generator" content="Hexo 3.9.0">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png?v=7.3.0">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png?v=7.3.0">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png?v=7.3.0">
  <link rel="mask-icon" href="/images/logo.svg?v=7.3.0" color="#222">

<link rel="stylesheet" href="/css/main.css?v=7.3.0">


<link rel="stylesheet" href="/lib/font-awesome/css/font-awesome.min.css?v=4.7.0">


<script id="hexo-configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Muse',
    version: '7.3.0',
    exturl: false,
    sidebar: {"position":"left","display":"post","offset":12,"onmobile":false},
    back2top: {"enable":true,"sidebar":false,"scrollpercent":false},
    save_scroll: false,
    copycode: {"enable":false,"show_result":false,"style":null},
    fancybox: false,
    mediumzoom: false,
    lazyload: false,
    pangu: false,
    algolia: {
      appID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    },
    localsearch: {"enable":false,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},
    path: '',
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    translation: {
      copy_button: '复制',
      copy_success: '复制成功',
      copy_failure: '复制失败'
    }
  };
</script>

  <meta name="description" content="C++11 &amp;amp; C++14 &amp;amp; C++17 常用新特性总结GCC编译器（从编译器GCC4.8.X的版本完全支持）　　（1）目前C++11特性，之前成为C++0X特性，从GCC4.3的后续版本中逐步对C++11进行支持。 　　（2）从官方信息可以看到，目前从完全对C++11特性进行支持的是从编译器GCC4.8.X的版本。 　　参考网址：https://gcc.gnu.org/proj">
<meta name="keywords" content="C++11">
<meta property="og:type" content="article">
<meta property="og:title" content="C++常用新特性">
<meta property="og:url" content="http://yoursite.com/2019/06/05/C++新特性/index.html">
<meta property="og:site_name" content="XuQi&#39;s Blog">
<meta property="og:description" content="C++11 &amp;amp; C++14 &amp;amp; C++17 常用新特性总结GCC编译器（从编译器GCC4.8.X的版本完全支持）　　（1）目前C++11特性，之前成为C++0X特性，从GCC4.3的后续版本中逐步对C++11进行支持。 　　（2）从官方信息可以看到，目前从完全对C++11特性进行支持的是从编译器GCC4.8.X的版本。 　　参考网址：https://gcc.gnu.org/proj">
<meta property="og:locale" content="zh-CN">
<meta property="og:updated_time" content="2019-10-20T13:23:23.037Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="C++常用新特性">
<meta name="twitter:description" content="C++11 &amp;amp; C++14 &amp;amp; C++17 常用新特性总结GCC编译器（从编译器GCC4.8.X的版本完全支持）　　（1）目前C++11特性，之前成为C++0X特性，从GCC4.3的后续版本中逐步对C++11进行支持。 　　（2）从官方信息可以看到，目前从完全对C++11特性进行支持的是从编译器GCC4.8.X的版本。 　　参考网址：https://gcc.gnu.org/proj">
  <link rel="canonical" href="http://yoursite.com/2019/06/05/C++新特性/">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome: false,
    isPost: true,
    isPage: false,
    isArchive: false
  };
</script>

  <title>C++常用新特性 | XuQi's Blog</title>
  








  <noscript>
  <style>
  .use-motion .motion-element,
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-title { opacity: initial; }

  .use-motion .logo,
  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-CN">

  <div class="container sidebar-position-left">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta">

    <div class="custom-logo-site-title">
      <a href="/" class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">XuQi's Blog</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
  </div>

  <div class="site-nav-toggle">
    <button aria-label="切换导航栏">
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>


<nav class="site-nav">
  
  <ul id="menu" class="menu">
      
      
      
        
        <li class="menu-item menu-item-home">
      
    

    <a href="/" rel="section"><i class="menu-item-icon fa fa-fw fa-home"></i> <br>首页</a>

  </li>
      
      
      
        
        <li class="menu-item menu-item-archives">
      
    

    <a href="/archives/" rel="section"><i class="menu-item-icon fa fa-fw fa-archive"></i> <br>归档</a>

  </li>
  </ul>

    

</nav>
</div>
    </header>

    


    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content page-post-detail">
            

  <div id="posts" class="posts-expand">
    

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://yoursite.com/2019/06/05/C++新特性/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="XuQi">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="XuQi's Blog">
    </span>
      <header class="post-header">

        
          <h1 class="post-title" itemprop="name headline">C++常用新特性

            
          </h1>
        

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              
                
              

              <time title="创建时间：2019-06-05 08:56:01" itemprop="dateCreated datePublished" datetime="2019-06-05T08:56:01+00:00">2019-06-05</time>
            </span>
          
            

            
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="fa fa-calendar-check-o"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2019-10-20 13:23:23" itemprop="dateModified" datetime="2019-10-20T13:23:23+00:00">2019-10-20</time>
              </span>
            
          

          

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
        <h1 id="C-11-amp-C-14-amp-C-17-常用新特性总结"><a href="#C-11-amp-C-14-amp-C-17-常用新特性总结" class="headerlink" title="C++11 &amp; C++14 &amp; C++17 常用新特性总结"></a>C++11 &amp; C++14 &amp; C++17 常用新特性总结</h1><h2 id="GCC编译器（从编译器GCC4-8-X的版本完全支持）"><a href="#GCC编译器（从编译器GCC4-8-X的版本完全支持）" class="headerlink" title="GCC编译器（从编译器GCC4.8.X的版本完全支持）"></a>GCC编译器<strong>（从编译器GCC4.8.X的版本完全支持）</strong></h2><p>　　（1）目前C++11特性，之前成为C++0X特性，从GCC4.3的后续版本中逐步对C++11进行支持。</p>
<p>　　（2）从官方信息可以看到，目前从完全对C++11特性进行支持的是从编译器GCC4.8.X的版本。</p>
<p>　　参考网址：<a href="https://gcc.gnu.org/projects/cxx-status.html#cxx11" target="_blank" rel="noopener">https://gcc.gnu.org/projects/cxx-status.html#cxx11</a></p>
<p>​        编译的时候加上参数：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">-std=c++11</span><br></pre></td></tr></table></figure>

<h2 id="C-11新特性"><a href="#C-11新特性" class="headerlink" title="C+11新特性"></a>C+11新特性</h2><h3 id="nullptr"><a href="#nullptr" class="headerlink" title="nullptr"></a>nullptr</h3><p>传统 C++ 会把 NULL、0 视为同一种东西，这取决于编译器如何定义NULL，有些编译器会将 NULL 定义为 ((void*)0)，有些则会直接将其定义为 0.</p>
<p>C++ 不允许直接将 void * 隐式转换到其他类型，但如果 NULL 被定义为 ((void*)0)，那么当编译char *ch = NULL;时，NULL 只好被定义为 0。</p>
<p>这样就会导致重载特性混乱，比如foo(NULL)调用的是foo(int)</p>
<figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">foo</span><span class="params">(<span class="keyword">char</span> *)</span></span>;</span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">foo</span><span class="params">(<span class="keyword">int</span>)</span></span>;</span><br></pre></td></tr></table></figure>

<a id="more"></a>

<h3 id="类型推导-auto和decltype"><a href="#类型推导-auto和decltype" class="headerlink" title="类型推导 auto和decltype"></a>类型推导 auto和decltype</h3><h4 id="auto"><a href="#auto" class="headerlink" title="auto"></a>auto</h4><p>常见用法：</p>
<figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">for</span>(<span class="built_in">vector</span>&lt;<span class="keyword">int</span>&gt;::const_iterator it = vec.begin(); it != vec.end(); it++) <span class="comment">// 不使用推导</span></span><br><span class="line"><span class="keyword">for</span>(<span class="keyword">auto</span> it = vec.begin(); it != end(); it++) <span class="comment">// 使用推导</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">auto</span> i = <span class="number">5</span>; <span class="comment">// i被推导为int</span></span><br><span class="line"><span class="keyword">auto</span> j = <span class="keyword">new</span> <span class="keyword">auto</span>(<span class="number">5</span>); <span class="comment">// j 被推导为int</span></span><br></pre></td></tr></table></figure>

<p>错误用法：</p>
<figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="keyword">int</span> <span class="title">foo</span><span class="params">(<span class="keyword">auto</span> i,<span class="keyword">auto</span> j)</span></span>; <span class="comment">// 传参数，类型未定义，无法重载，无法通过编译</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">int</span> ary[<span class="number">5</span>] = &#123;<span class="number">0</span>&#125;;</span><br><span class="line"><span class="keyword">auto</span> ary1 = ary; <span class="comment">// 无法推导数组</span></span><br></pre></td></tr></table></figure>

<h4 id="decltype"><a href="#decltype" class="headerlink" title="decltype"></a>decltype</h4><p>为了解决auto只能对变量推导的缺陷，所以decltype的用法是 decltype(表达是)</p>
<figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">auto</span> i = <span class="number">4</span>;</span><br><span class="line"><span class="keyword">auto</span> j = <span class="number">5</span>;</span><br><span class="line"><span class="keyword">decltype</span>(i+j) x; <span class="comment">// int类型</span></span><br></pre></td></tr></table></figure>

<h4 id="拖尾类型返回"><a href="#拖尾类型返回" class="headerlink" title="拖尾类型返回"></a>拖尾类型返回</h4><figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">template</span>&lt;<span class="keyword">typename</span> R,<span class="keyword">typename</span> T,<span class="keyword">typename</span> U&gt;  <span class="comment">//返回类型也要指定</span></span><br><span class="line"><span class="function">R <span class="title">add</span><span class="params">(T x,U y)</span> </span>&#123;</span><br><span class="line">   <span class="keyword">return</span> x+y;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="keyword">template</span>&lt;<span class="keyword">typename</span> T,<span class="keyword">typename</span> U&gt;  <span class="comment">//无法编译通过， 期待自动推导，但是x，y未定义</span></span><br><span class="line"><span class="keyword">decltype</span>(x+y) add(T x,U y) &#123;</span><br><span class="line">   <span class="keyword">return</span> x+y;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="keyword">template</span>&lt;<span class="keyword">typename</span> T,<span class="keyword">typename</span> U&gt;</span><br><span class="line">auto add(T x,U y) -&gt; decltype(x+y) // C++11 需要通过拖尾类型返回实现</span><br><span class="line">&#123;</span><br><span class="line">    <span class="keyword">return</span> x+y</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="keyword">template</span>&lt;<span class="keyword">typename</span> T,<span class="keyword">typename</span> U&gt;</span><br><span class="line"><span class="keyword">auto</span> add(T x,U y) &#123; <span class="comment">// C++14 直接支持</span></span><br><span class="line">    <span class="keyword">return</span> x+y</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h3 id="区间迭代"><a href="#区间迭代" class="headerlink" title="区间迭代"></a>区间迭代</h3><p>常见用法:</p>
<figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">for</span> (<span class="built_in">vector</span>&lt;<span class="keyword">int</span>&gt;::const_iterator it = vec.begin(); it != vec.end(); it++) <span class="comment">// 不使用推导</span></span><br><span class="line"><span class="keyword">for</span> (<span class="keyword">auto</span> &amp;i: vec)</span><br><span class="line">&#123;</span><br><span class="line">    <span class="built_in">cout</span> &lt;&lt; i &lt;&lt; <span class="built_in">endl</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h3 id="初始化列表"><a href="#初始化列表" class="headerlink" title="初始化列表"></a>初始化列表</h3><p>c++提供了统一的语法初始化任意的对象</p>
<figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line"><span class="class"><span class="keyword">struct</span> <span class="title">A</span> &#123;</span></span><br><span class="line">	<span class="keyword">int</span> a;</span><br><span class="line"> 	<span class="keyword">float</span> b;</span><br><span class="line">&#125;;</span><br><span class="line"></span><br><span class="line"><span class="class"><span class="keyword">struct</span> <span class="title">B</span> &#123;</span></span><br><span class="line">  B(<span class="keyword">int</span> _a,<span class="keyword">float</span> _b): a(_a),b(_b) &#123;&#125;</span><br><span class="line"><span class="keyword">private</span>:</span><br><span class="line">  <span class="keyword">int</span> a;</span><br><span class="line">  <span class="keyword">float</span> b;</span><br><span class="line">&#125;;</span><br><span class="line"></span><br><span class="line">A a&#123;<span class="number">1</span>,<span class="number">1.1</span>&#125;;</span><br><span class="line">B b&#123;<span class="number">2</span>,<span class="number">2.2</span>&#125;;</span><br></pre></td></tr></table></figure>

<h3 id="模板增强"><a href="#模板增强" class="headerlink" title="模板增强"></a>模板增强</h3><h4 id="尖括号-“-gt-”"><a href="#尖括号-“-gt-”" class="headerlink" title="尖括号 “&gt;”"></a>尖括号 “&gt;”</h4><p>在传统 C++ 的编译器中，&gt;&gt;一律被当做右移运算符来进行处理。C++11 开始，连续的右尖括号将变得合法，并且能够顺利通过编译。</p>
<figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">std</span>::<span class="built_in">vector</span>&lt;<span class="built_in">std</span>::<span class="built_in">vector</span>&lt;<span class="keyword">int</span>&gt;&gt; wow;</span><br></pre></td></tr></table></figure>

<h3 id="构造函数"><a href="#构造函数" class="headerlink" title="构造函数"></a>构造函数</h3><h4 id="委托构造"><a href="#委托构造" class="headerlink" title="委托构造"></a>委托构造</h4><p>构造函数可以在同一个类中一个构造函数调用另一个构造函数</p>
<figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"><span class="class"><span class="keyword">class</span> <span class="title">Base</span> &#123;</span></span><br><span class="line"><span class="keyword">public</span>:</span><br><span class="line">    <span class="keyword">int</span> value1;</span><br><span class="line">    <span class="keyword">int</span> value2;</span><br><span class="line">    Base() &#123;</span><br><span class="line">        value1 = <span class="number">1</span>;</span><br><span class="line">    &#125;</span><br><span class="line">    Base(<span class="keyword">int</span> value) : Base() &#123;  <span class="comment">// 委托 Base() 构造函数</span></span><br><span class="line">        value2 = <span class="number">2</span>;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;;</span><br></pre></td></tr></table></figure>

<h4 id="继承构造"><a href="#继承构造" class="headerlink" title="继承构造"></a>继承构造</h4><p>使用继承构造之前</p>
<figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line"><span class="class"><span class="keyword">struct</span> <span class="title">A</span></span></span><br><span class="line"><span class="class">&#123;</span></span><br><span class="line">  A(<span class="keyword">int</span> i) &#123;&#125;</span><br><span class="line">  A(<span class="keyword">double</span> d,<span class="keyword">int</span> i)&#123;&#125;</span><br><span class="line">  A(<span class="keyword">float</span> f,<span class="keyword">int</span> i,<span class="keyword">const</span> <span class="keyword">char</span>* c)&#123;&#125;</span><br><span class="line">  <span class="comment">//...等等系列的构造函数版本</span></span><br><span class="line">&#125;；</span><br><span class="line"><span class="class"><span class="keyword">struct</span> <span class="title">B</span>:</span>A</span><br><span class="line">&#123;</span><br><span class="line">  B(<span class="keyword">int</span> i):A(i)&#123;&#125;</span><br><span class="line">  B(<span class="keyword">double</span> d,<span class="keyword">int</span> i):A(d,i)&#123;&#125;</span><br><span class="line">  B(folat f,<span class="keyword">int</span> i,<span class="keyword">const</span> <span class="keyword">char</span>* c):A(f,i,e)&#123;&#125;</span><br><span class="line">  <span class="comment">//......等等好多个和基类构造函数对应的构造函数</span></span><br><span class="line">&#125;；</span><br></pre></td></tr></table></figure>

<p>C++11的继承构造后</p>
<figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line"><span class="class"><span class="keyword">struct</span> <span class="title">A</span></span></span><br><span class="line"><span class="class">&#123;</span></span><br><span class="line">  A(<span class="keyword">int</span> i) &#123;&#125;</span><br><span class="line">  A(<span class="keyword">double</span> d,<span class="keyword">int</span> i)&#123;&#125;</span><br><span class="line">  A(<span class="keyword">float</span> f,<span class="keyword">int</span> i,<span class="keyword">const</span> <span class="keyword">char</span>* c)&#123;&#125;</span><br><span class="line">  <span class="comment">//...等等系列的构造函数版本</span></span><br><span class="line">&#125;；</span><br><span class="line"><span class="class"><span class="keyword">struct</span> <span class="title">B</span>:</span>A</span><br><span class="line">&#123;</span><br><span class="line">  <span class="keyword">using</span> A::A;</span><br><span class="line">  <span class="comment">//关于基类各构造函数的继承一句话搞定</span></span><br><span class="line">  <span class="comment">//......</span></span><br><span class="line">&#125;；</span><br></pre></td></tr></table></figure>

<h3 id="Lambda-表达式"><a href="#Lambda-表达式" class="headerlink" title="Lambda 表达式"></a>Lambda 表达式</h3><p>Lambda 表达式，实际上就是提供了一个类似匿名函数的特性</p>
<figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">[ caputrue ] ( params ) opt -&gt; ret &#123; body; &#125;;</span><br></pre></td></tr></table></figure>

<ol>
<li>capture是捕获列表； </li>
<li>params是参数表；(选填) </li>
<li>opt是函数选项；可以填mutable,exception,attribute（选填）<br>mutable说明lambda表达式体内的代码可以修改被捕获的变量，并且可以访问被捕获的对象的non-const方法。<br>exception说明lambda表达式是否抛出异常以及何种异常。<br>attribute用来声明属性。 </li>
<li>ret是返回值类型（拖尾返回类型）。(选填) </li>
<li>body是函数体。</li>
</ol>
<p><strong>捕获列表</strong>：lambda表达式的捕获列表精细控制了lambda表达式能够访问的外部变量，以及如何访问这些变量。</p>
<p>1) []不捕获任何变量。<br>2) [&amp;]捕获外部作用域中所有变量，并作为引用在函数体中使用（按引用捕获）。 </p>
<p>3) [=]捕获外部作用域中所有变量，并作为副本在函数体中使用(按值捕获)。注意值捕获的前提是变量可以拷贝，且被捕获的变量在 lambda 表达式被创建时拷贝，而非调用时才拷贝。如果希望lambda表达式在调用时能即时访问外部变量，我们应当使用引用方式捕获。</p>
<figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">int</span> a = <span class="number">0</span>;</span><br><span class="line"><span class="keyword">auto</span> f = [=] &#123; <span class="keyword">return</span> a; &#125;; <span class="comment">//在函数内，拷贝一份a的值，所以无法改变他的值</span></span><br><span class="line">a+=<span class="number">1</span>;</span><br><span class="line"><span class="built_in">cout</span> &lt;&lt; f() &lt;&lt; <span class="built_in">endl</span>;       <span class="comment">//输出0</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">int</span> a = <span class="number">0</span>;</span><br><span class="line"><span class="keyword">auto</span> f = [&amp;a] &#123; <span class="keyword">return</span> a; &#125;; <span class="comment">// 在函数内，引用外部变量，可以改变他的值</span></span><br><span class="line">a+=<span class="number">1</span>;</span><br><span class="line"><span class="built_in">cout</span> &lt;&lt; f() &lt;&lt;<span class="built_in">endl</span>;       <span class="comment">//输出1</span></span><br></pre></td></tr></table></figure>

<p>4) [=,&amp;foo]按值捕获外部作用域中所有变量，并按引用捕获foo变量。<br>5) [bar]按值捕获bar变量，同时不捕获其他变量。 </p>
<p>6) [this]捕获当前类中的this指针，让lambda表达式拥有和当前类成员函数同样的访问权限。如果已经使用了&amp;或者=，就默认添加此选项。捕获this的目的是可以在lamda中使用当前类的成员函数和成员变量。</p>
<figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br></pre></td><td class="code"><pre><span class="line"><span class="class"><span class="keyword">class</span> <span class="title">A</span></span></span><br><span class="line"><span class="class">&#123;</span></span><br><span class="line"> <span class="keyword">public</span>:</span><br><span class="line">     <span class="keyword">int</span> i_ = <span class="number">0</span>;</span><br><span class="line"></span><br><span class="line">     <span class="function"><span class="keyword">void</span> <span class="title">func</span><span class="params">(<span class="keyword">int</span> x,<span class="keyword">int</span> y)</span></span>&#123;</span><br><span class="line">         <span class="keyword">auto</span> x1 = [] &#123; <span class="keyword">return</span> i_; &#125;;                   <span class="comment">//error,没有捕获外部变量</span></span><br><span class="line">         <span class="keyword">auto</span> x2 = [=] &#123; <span class="keyword">return</span> i_ + x + y; &#125;;          <span class="comment">//OK</span></span><br><span class="line">         <span class="keyword">auto</span> x3 = [&amp;] &#123; <span class="keyword">return</span> i_ + x + y; &#125;;        <span class="comment">//OK</span></span><br><span class="line">         <span class="keyword">auto</span> x4 = [<span class="keyword">this</span>] &#123; <span class="keyword">return</span> i_; &#125;;               <span class="comment">//OK</span></span><br><span class="line">         <span class="keyword">auto</span> x5 = [<span class="keyword">this</span>] &#123; <span class="keyword">return</span> i_ + x + y; &#125;;       <span class="comment">//error,没有捕获x,y</span></span><br><span class="line">         <span class="keyword">auto</span> x6 = [<span class="keyword">this</span>, x, y] &#123; <span class="keyword">return</span> i_ + x + y; &#125;;     <span class="comment">//OK</span></span><br><span class="line">         <span class="keyword">auto</span> x7 = [<span class="keyword">this</span>] &#123; <span class="keyword">return</span> i_++; &#125;;             <span class="comment">//OK</span></span><br><span class="line">&#125;;</span><br><span class="line"></span><br><span class="line"><span class="keyword">int</span> a=<span class="number">0</span> , b=<span class="number">1</span>;</span><br><span class="line"><span class="keyword">auto</span> f1 = [] &#123; <span class="keyword">return</span> a; &#125;;                         <span class="comment">//error,没有捕获外部变量    </span></span><br><span class="line"><span class="keyword">auto</span> f2 = [&amp;] &#123; <span class="keyword">return</span> a++ &#125;;                      <span class="comment">//OK</span></span><br><span class="line"><span class="keyword">auto</span> f3 = [=] &#123; <span class="keyword">return</span> a; &#125;;                        <span class="comment">//OK</span></span><br><span class="line"><span class="keyword">auto</span> f4 = [=] &#123;<span class="keyword">return</span> a++; &#125;;                       <span class="comment">//error,a是以复制方式捕获的，无法修改</span></span><br><span class="line"><span class="keyword">auto</span> f5 = [a] &#123; <span class="keyword">return</span> a+b; &#125;;                      <span class="comment">//error,没有捕获变量b</span></span><br><span class="line"><span class="keyword">auto</span> f6 = [a, &amp;b] &#123; <span class="keyword">return</span> a + (b++); &#125;;                <span class="comment">//OK</span></span><br><span class="line"><span class="keyword">auto</span> f7 = [=, &amp;b] &#123; <span class="keyword">return</span> a + (b++); &#125;;                <span class="comment">//OK</span></span><br></pre></td></tr></table></figure>

<p><strong>注意f4</strong>，虽然按值捕获的变量值均复制一份存储在lambda表达式变量中，修改他们也并不会真正影响到外部，<strong>但我们却仍然无法修改它们。</strong>如果希望去修改按值捕获的外部变量，需要显示指明lambda表达式为mutable。被mutable修饰的lambda表达式就算没有参数也要写明参数列表。</p>
<p>原因：lambda表达式可以说是就地定义仿函数闭包的“语法糖”。它的捕获列表捕获住的任何外部变量，最终会变为闭包类型的成员变量。按照C++标准，lambda表达式的operator()默认是const的，一个const成员函数是无法修改成员变量的值的。而mutable的作用，就在于取消operator()的const。</p>
<figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">int</span> a = <span class="number">0</span>;</span><br><span class="line"><span class="keyword">auto</span> f1 = [=] &#123; <span class="keyword">return</span> a++; &#125;;                <span class="comment">//error</span></span><br><span class="line"><span class="keyword">auto</span> f2 = [=] () <span class="keyword">mutable</span> &#123; <span class="keyword">return</span> a++; &#125;;       <span class="comment">//OK</span></span><br></pre></td></tr></table></figure>

<p>lambda表达式是不能被赋值的：</p>
<figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">auto</span> a = [] &#123; <span class="built_in">cout</span> &lt;&lt; <span class="string">"A"</span> &lt;&lt; <span class="built_in">endl</span>; &#125;;</span><br><span class="line"><span class="keyword">auto</span> b = [] &#123; <span class="built_in">cout</span> &lt;&lt; <span class="string">"B"</span> &lt;&lt; <span class="built_in">endl</span>; &#125;;</span><br><span class="line"></span><br><span class="line">a = b;   <span class="comment">// 非法，lambda无法赋值</span></span><br><span class="line"><span class="keyword">auto</span> c = a;   <span class="comment">// 合法，生成一个副本</span></span><br></pre></td></tr></table></figure>

<p>闭包类型禁用了赋值操作符，但是没有禁用复制构造函数，所以你仍然可以用一个lambda表达式去初始化另外一个lambda表达式而产生副本。</p>
<p>在多种捕获方式中，<strong>最好不要使用[=]和[&amp;]默认捕获所有变量</strong>。</p>
<figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">std</span>::function&lt;<span class="keyword">int</span>(<span class="keyword">int</span>)&gt; add_x(<span class="keyword">int</span> x)</span><br><span class="line">&#123;</span><br><span class="line">    <span class="keyword">return</span> [&amp;](<span class="keyword">int</span> a) &#123; <span class="keyword">return</span> x + a; &#125;;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p><strong>悬挂引用</strong>，返回了一个lambda表达式，参数x仅是一个临时变量，函数add_x调用后就被销毁了，但是返回的lambda表达式却引用了该变量，当调用这个表达式时，引用的是一个垃圾值，会产生没有意义的结果。</p>
<p>采用默认值捕获所有变量仍然有风险</p>
<figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line"><span class="class"><span class="keyword">class</span> <span class="title">Filter</span></span></span><br><span class="line"><span class="class">&#123;</span></span><br><span class="line"><span class="keyword">public</span>:</span><br><span class="line">    Filter(<span class="keyword">int</span> divisorVal):</span><br><span class="line">        divisor&#123;divisorVal&#125;</span><br><span class="line">    &#123;&#125;</span><br><span class="line"></span><br><span class="line">    <span class="built_in">std</span>::function&lt;<span class="keyword">bool</span>(<span class="keyword">int</span>)&gt; getFilter() </span><br><span class="line">    &#123;</span><br><span class="line">        <span class="keyword">return</span> [=](<span class="keyword">int</span> value) &#123;<span class="keyword">return</span> value % divisor == <span class="number">0</span>; &#125;;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line"><span class="keyword">private</span>:</span><br><span class="line">    <span class="keyword">int</span> divisor;</span><br><span class="line">&#125;;</span><br></pre></td></tr></table></figure>

<p>这个类中有一个成员方法，可以返回一个lambda表达式，这个表达式使用了类的数据成员divisor。而且采用默认值方式捕捉所有变量。lambda表达式无法捕捉divisor的副本，<strong>因为数据成员divisor对lambda表达式并不可见</strong></p>
<p><strong>错误</strong></p>
<figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">std</span>::function&lt;<span class="keyword">bool</span>(<span class="keyword">int</span>)&gt; getFilter() </span><br><span class="line">&#123;</span><br><span class="line">    <span class="keyword">return</span> [divisor](<span class="keyword">int</span> value) &#123;<span class="keyword">return</span> value % divisor == <span class="number">0</span>; &#125;;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p><strong>正确</strong></p>
<figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">std</span>::function&lt;<span class="keyword">bool</span>(<span class="keyword">int</span>)&gt; getFilter() </span><br><span class="line">&#123;</span><br><span class="line">    <span class="keyword">return</span> [<span class="keyword">this</span>](<span class="keyword">int</span> value) &#123;<span class="keyword">return</span> value % <span class="keyword">this</span>-&gt;divisor == <span class="number">0</span>; &#125;;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>实现函数回调，类似函数指针</p>
<figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">std</span>::function&lt;<span class="keyword">bool</span>(<span class="keyword">int</span>, <span class="keyword">int</span>)&gt; wrapper = [](<span class="keyword">int</span> x, <span class="keyword">int</span> y) &#123; <span class="keyword">return</span> x &lt; y; &#125;;</span><br></pre></td></tr></table></figure>

<p>最常用的是在STL算法中</p>
<figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">int</span> value = <span class="number">3</span>;</span><br><span class="line"><span class="built_in">vector</span>&lt;<span class="keyword">int</span>&gt; v &#123;<span class="number">1</span>, <span class="number">3</span>, <span class="number">5</span>, <span class="number">2</span>, <span class="number">6</span>, <span class="number">10</span>&#125;;</span><br><span class="line"><span class="keyword">int</span> count = <span class="built_in">std</span>::count_if(v.beigin(), v.end(), [value](<span class="keyword">int</span> x) &#123; <span class="keyword">return</span> x &gt; value; &#125;);</span><br></pre></td></tr></table></figure>

<p>生成斐波那契数列，然后保存在数组中</p>
<figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">vector</span>&lt;<span class="keyword">int</span>&gt; v(<span class="number">10</span>);</span><br><span class="line"><span class="keyword">int</span> a = <span class="number">0</span>;</span><br><span class="line"><span class="keyword">int</span> b = <span class="number">1</span>;</span><br><span class="line"><span class="built_in">std</span>::generate(v.begin(), v.end(), [&amp;a, &amp;b] &#123; <span class="keyword">int</span> value = b; b = b + a; a = value; <span class="keyword">return</span> value; &#125;);</span><br><span class="line"><span class="comment">// 此时v &#123;1, 1, 2, 3, 5, 8, 13, 21, 34, 55&#125;</span></span><br></pre></td></tr></table></figure>

<p>当需要遍历容器并对每个元素进行操作时</p>
<figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">std</span>::<span class="built_in">vector</span>&lt;<span class="keyword">int</span>&gt; v = &#123; <span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>, <span class="number">4</span>, <span class="number">5</span>, <span class="number">6</span> &#125;;</span><br><span class="line"><span class="keyword">int</span> even_count = <span class="number">0</span>;</span><br><span class="line">for_each(v.begin(), v.end(), [&amp;even_count](<span class="keyword">int</span> val)&#123;</span><br><span class="line">    <span class="keyword">if</span>(!(val &amp; <span class="number">1</span>))&#123;</span><br><span class="line">        ++ even_count;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;);</span><br><span class="line"><span class="built_in">std</span>::<span class="built_in">cout</span> &lt;&lt; <span class="string">"The number of even is "</span> &lt;&lt; even_count &lt;&lt; <span class="built_in">std</span>::<span class="built_in">endl</span>;</span><br></pre></td></tr></table></figure>

<h3 id="新增容器"><a href="#新增容器" class="headerlink" title="新增容器"></a>新增容器</h3><h4 id="std-array"><a href="#std-array" class="headerlink" title="std::array"></a>std::array</h4><h4 id="std-forward-list"><a href="#std-forward-list" class="headerlink" title="std::forward_list"></a>std::forward_list</h4><h4 id="无序容器"><a href="#无序容器" class="headerlink" title="无序容器"></a>无序容器</h4><h4 id="元组-std-tuple"><a href="#元组-std-tuple" class="headerlink" title="元组 std::tuple"></a>元组 std::tuple</h4><p>std::make_tuple: 构造元组<br>std::get: 获得元组某个位置的值<br>std::tie: 元组拆包</p>
<figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;tuple&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;iostream&gt;</span></span></span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">auto</span> <span class="title">get_student</span><span class="params">(<span class="keyword">int</span> id)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    <span class="comment">// 返回类型被推断为 std::tuple&lt;double, char, std::string&gt;</span></span><br><span class="line">    <span class="keyword">if</span> (id == <span class="number">0</span>)</span><br><span class="line">        <span class="keyword">return</span> <span class="built_in">std</span>::make_tuple(<span class="number">3.8</span>, <span class="string">'A'</span>, <span class="string">"张三"</span>);</span><br><span class="line">    <span class="keyword">if</span> (id == <span class="number">1</span>)</span><br><span class="line">        <span class="keyword">return</span> <span class="built_in">std</span>::make_tuple(<span class="number">2.9</span>, <span class="string">'C'</span>, <span class="string">"李四"</span>);</span><br><span class="line">    <span class="keyword">if</span> (id == <span class="number">2</span>)</span><br><span class="line">        <span class="keyword">return</span> <span class="built_in">std</span>::make_tuple(<span class="number">1.7</span>, <span class="string">'D'</span>, <span class="string">"王五"</span>);</span><br><span class="line">    <span class="keyword">return</span> <span class="built_in">std</span>::make_tuple(<span class="number">0.0</span>, <span class="string">'D'</span>, <span class="string">"null"</span>);   </span><br><span class="line">    <span class="comment">// 如果只写 0 会出现推断错误, 编译失败</span></span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">int</span> <span class="title">main</span><span class="params">()</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    <span class="keyword">auto</span> student = get_student(<span class="number">0</span>);</span><br><span class="line">    <span class="built_in">std</span>::<span class="built_in">cout</span> &lt;&lt; <span class="string">"ID: 0, "</span></span><br><span class="line">    &lt;&lt; <span class="string">"GPA: "</span> &lt;&lt; <span class="built_in">std</span>::get&lt;<span class="number">0</span>&gt;(student) &lt;&lt; <span class="string">", "</span></span><br><span class="line">    &lt;&lt; <span class="string">"成绩: "</span> &lt;&lt; <span class="built_in">std</span>::get&lt;<span class="number">1</span>&gt;(student) &lt;&lt; <span class="string">", "</span></span><br><span class="line">    &lt;&lt; <span class="string">"姓名: "</span> &lt;&lt; <span class="built_in">std</span>::get&lt;<span class="number">2</span>&gt;(student) &lt;&lt; <span class="string">'\n'</span>;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">double</span> gpa;</span><br><span class="line">    <span class="keyword">char</span> grade;</span><br><span class="line">    <span class="built_in">std</span>::<span class="built_in">string</span> name;</span><br><span class="line"></span><br><span class="line">    <span class="comment">// 元组进行拆包</span></span><br><span class="line">    <span class="built_in">std</span>::tie(gpa, grade, name) = get_student(<span class="number">1</span>);</span><br><span class="line">    <span class="built_in">std</span>::<span class="built_in">cout</span> &lt;&lt; <span class="string">"ID: 1, "</span></span><br><span class="line">    &lt;&lt; <span class="string">"GPA: "</span> &lt;&lt; gpa &lt;&lt; <span class="string">", "</span></span><br><span class="line">    &lt;&lt; <span class="string">"成绩: "</span> &lt;&lt; grade &lt;&lt; <span class="string">", "</span></span><br><span class="line">    &lt;&lt; <span class="string">"姓名: "</span> &lt;&lt; name &lt;&lt; <span class="string">'\n'</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h3 id="正则表达式"><a href="#正则表达式" class="headerlink" title="正则表达式"></a>正则表达式</h3><ol>
<li>检查一个串是否包含某种形式的子串； </li>
<li>将匹配的子串替换； </li>
<li>从某个串中取出符合条件的子串。</li>
</ol>
<figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;iostream&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;string&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;regex&gt;</span></span></span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">int</span> <span class="title">main</span><span class="params">()</span> </span>&#123;</span><br><span class="line">    <span class="built_in">std</span>::<span class="built_in">string</span> fnames[] = &#123;<span class="string">"foo.txt"</span>, <span class="string">"bar.txt"</span>, <span class="string">"test"</span>, <span class="string">"a0.txt"</span>, <span class="string">"AAA.txt"</span>&#125;;</span><br><span class="line">    <span class="comment">// 在 C++ 中 `\` 会被作为字符串内的转义符，为使 `\.` 作为正则表达式传递进去生效，需要对 `\` 进行二次转义，从而有 `\\.`</span></span><br><span class="line">    <span class="built_in">std</span>::<span class="function">regex <span class="title">txt_regex</span><span class="params">(<span class="string">"[a-z]+\\.txt"</span>)</span></span>;</span><br><span class="line">    <span class="keyword">for</span> (<span class="keyword">const</span> <span class="keyword">auto</span> &amp;fname: fnames)</span><br><span class="line">        <span class="built_in">std</span>::<span class="built_in">cout</span> &lt;&lt; fname &lt;&lt; <span class="string">": "</span> &lt;&lt; <span class="built_in">std</span>::regex_match(fname, txt_regex) &lt;&lt; <span class="built_in">std</span>::<span class="built_in">endl</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h3 id="语言级线程支持"><a href="#语言级线程支持" class="headerlink" title="语言级线程支持"></a>语言级线程支持</h3><p>std::mutex/std::unique_lock<br>std::future/std::packaged_task<br>std::condition_variable</p>
<p>代码编译需要使用 -pthread 选项</p>
<h3 id="右值引用-amp-amp"><a href="#右值引用-amp-amp" class="headerlink" title="右值引用&amp;&amp;"></a>右值引用&amp;&amp;</h3><ol>
<li>消除两个对象交互时不必要的对象拷贝，节省运算存储资源，提高效率。 </li>
<li>能够更简洁明确地定义泛型函数。</li>
</ol>
<figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br></pre></td><td class="code"><pre><span class="line"><span class="class"><span class="keyword">class</span> <span class="title">MyString</span> &#123;</span></span><br><span class="line"><span class="keyword">private</span>:</span><br><span class="line">    <span class="keyword">char</span>* _data;</span><br><span class="line">    <span class="keyword">size_t</span>   _len;</span><br><span class="line">    <span class="keyword">void</span> _init_data(<span class="keyword">const</span> <span class="keyword">char</span> *s) &#123;</span><br><span class="line">        _data = <span class="keyword">new</span> <span class="keyword">char</span>[_len + <span class="number">1</span>];</span><br><span class="line">        <span class="built_in">memcpy</span>(_data, s, _len);</span><br><span class="line">        _data[_len] = <span class="string">'\0'</span>;</span><br><span class="line">    &#125;</span><br><span class="line"><span class="keyword">public</span>:</span><br><span class="line">    MyString() &#123;</span><br><span class="line">        _data = <span class="literal">NULL</span>;</span><br><span class="line">        _len = <span class="number">0</span>;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    MyString(<span class="keyword">const</span> <span class="keyword">char</span>* p) &#123;</span><br><span class="line">        _len = <span class="built_in">strlen</span>(p);</span><br><span class="line">        _init_data(p);</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    MyString(<span class="keyword">const</span> MyString&amp; str) &#123;</span><br><span class="line">        _len = str._len;</span><br><span class="line">        _init_data(str._data);</span><br><span class="line">        <span class="built_in">std</span>::<span class="built_in">cout</span> &lt;&lt; <span class="string">"Copy Constructor is called! source: "</span> &lt;&lt; str._data &lt;&lt; <span class="built_in">std</span>::<span class="built_in">endl</span>;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    MyString&amp; <span class="keyword">operator</span>=(<span class="keyword">const</span> MyString&amp; str) &#123;</span><br><span class="line">        <span class="keyword">if</span> (<span class="keyword">this</span> != &amp;str) &#123;</span><br><span class="line">            _len = str._len;</span><br><span class="line">            _init_data(str._data);</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="built_in">std</span>::<span class="built_in">cout</span> &lt;&lt; <span class="string">"Copy Assignment is called! source: "</span> &lt;&lt; str._data &lt;&lt; <span class="built_in">std</span>::<span class="built_in">endl</span>;</span><br><span class="line">        <span class="keyword">return</span> *<span class="keyword">this</span>;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">virtual</span> ~MyString() &#123;</span><br><span class="line">        <span class="keyword">if</span> (_data != <span class="literal">NULL</span>) &#123;</span><br><span class="line">            <span class="built_in">std</span>::<span class="built_in">cout</span> &lt;&lt; <span class="string">"Destructor is called! "</span> &lt;&lt; <span class="built_in">std</span>::<span class="built_in">endl</span>; </span><br><span class="line">            <span class="built_in">free</span>(_data);</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">int</span> <span class="title">main</span><span class="params">()</span> </span>&#123; </span><br><span class="line">    MyString a; </span><br><span class="line">    a = MyString(<span class="string">"Hello"</span>);  <span class="comment">// 此处赋值函数</span></span><br><span class="line">    <span class="built_in">std</span>::<span class="built_in">vector</span>&lt;MyString&gt; vec; </span><br><span class="line">    vec.push_back(MyString(<span class="string">"World"</span>)); <span class="comment">// 此处拷贝构造函数</span></span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>运行结果</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">Copy Assignment is called! source: Hello</span><br><span class="line">Destructor is called!</span><br><span class="line">Copy Constructor is called! source: World</span><br><span class="line">Destructor is called!</span><br><span class="line">Destructor is called!</span><br><span class="line">Destructor is called!</span><br></pre></td></tr></table></figure>

<figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><span class="line">MyString(MyString&amp;&amp; str) &#123;  <span class="comment">//转移构造函数</span></span><br><span class="line">    <span class="built_in">std</span>::<span class="built_in">cout</span> &lt;&lt; <span class="string">"Move Constructor is called! source: "</span> &lt;&lt; str._data &lt;&lt; <span class="built_in">std</span>::<span class="built_in">endl</span>; </span><br><span class="line">    _len = str._len; </span><br><span class="line">    _data = str._data; </span><br><span class="line">    str._len = <span class="number">0</span>; </span><br><span class="line">    str._data = <span class="literal">NULL</span>;   <span class="comment">// ! 防止在析构函数中将内存释放掉</span></span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line">MyString&amp; <span class="keyword">operator</span>=(MyString&amp;&amp; str) &#123;  <span class="comment">//转移赋值操作符重载</span></span><br><span class="line">    <span class="built_in">std</span>::<span class="built_in">cout</span> &lt;&lt; <span class="string">"Move Assignment is called! source: "</span> &lt;&lt; str._data &lt;&lt; <span class="built_in">std</span>::<span class="built_in">endl</span>; </span><br><span class="line">    <span class="keyword">if</span> (<span class="keyword">this</span> != &amp;str) &#123; </span><br><span class="line">        _len = str._len; </span><br><span class="line">        _data = str._data; </span><br><span class="line">        str._len = <span class="number">0</span>; </span><br><span class="line">        str._data = <span class="literal">NULL</span>;  <span class="comment">// ! 防止在析构函数中将内存释放掉</span></span><br><span class="line">    &#125; </span><br><span class="line">    <span class="keyword">return</span> *<span class="keyword">this</span>; </span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p><strong>注</strong>：右值引用并不能阻止编译器在临时对象使用完之后将其释放掉的事实，所以<code>转移构造函数</code>和<code>转移赋值操作符重载函数</code> 中都将<code>_data</code>赋值为了<code>NULL</code>，而且析构函数中保证了<code>_data != NULL</code>才会释放。</p>
<h4 id="std-move"><a href="#std-move" class="headerlink" title="std::move"></a>std::move</h4><p>std::move并不能移动任何东西，它唯一的功能是将一个左值强制转化为右值引用，继而可以通过右值引用使用该值，以用于移动语义。从实现上讲，std::move基本等同于一个类型转换：static_cast&lt;T&amp;&amp;&gt;(lvalue)</p>
<ol>
<li>C++ 标准库使用比如vector::push_back 等这类函数时,会对参数的对象进行复制,连数据也会复制.这就会造成对象内存的额外创建, 本来原意是想把参数push_back进去就行了,<strong>通过std::move，可以避免不必要的拷贝操作。</strong></li>
<li>std::move是将对象的状态或者所有权从一个对象转移到另一个对象，只是转移，没有内存的搬迁或者内存拷贝所以可以提高利用效率,改善性能.。</li>
<li>对指针类型的标准库对象并不需要这么做.</li>
</ol>
<h4 id="命名对象使用-std-move右值引用"><a href="#命名对象使用-std-move右值引用" class="headerlink" title="命名对象使用 std::move右值引用"></a>命名对象使用 std::move右值引用</h4><p>既然编译器只对右值引用才能调用转移构造函数和转移赋值函数，又因为所有命名对象都只能是左值引用。 在这样的条件了，如果已知一个命名对象不再被使用而想对它调用转移构造函数和转移赋值函数，也就是把一个左值引用当做右值引用来使用，怎么做呢？标准库提供了函数 std::move，这个函数以非常简单的方式将左值引用转换为右值引用。</p>
<figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">ProcessValue</span><span class="params">(<span class="keyword">int</span>&amp; i)</span> </span>&#123; </span><br><span class="line">    <span class="built_in">std</span>::<span class="built_in">cout</span> &lt;&lt; <span class="string">"LValue processed: "</span> &lt;&lt; i &lt;&lt; <span class="built_in">std</span>::<span class="built_in">endl</span>; </span><br><span class="line">&#125; </span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">ProcessValue</span><span class="params">(<span class="keyword">int</span>&amp;&amp; i)</span> </span>&#123; </span><br><span class="line">    <span class="built_in">std</span>::<span class="built_in">cout</span> &lt;&lt; <span class="string">"RValue processed: "</span> &lt;&lt; i &lt;&lt; <span class="built_in">std</span>::<span class="built_in">endl</span>; </span><br><span class="line">&#125; </span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">int</span> <span class="title">main</span><span class="params">()</span> </span>&#123; </span><br><span class="line">    <span class="keyword">int</span> a = <span class="number">0</span>; </span><br><span class="line">    ProcessValue(a); </span><br><span class="line">    ProcessValue(<span class="built_in">std</span>::move(a)); <span class="comment">// 命名对象使用右值引用</span></span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>运行结果：</p>
<figure class="highlight powershell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">LValue processed: <span class="number">0</span> </span><br><span class="line">RValue processed: <span class="number">0</span></span><br></pre></td></tr></table></figure>

<p>std::move在提高 swap 函数的的性能上非常有帮助</p>
<figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">template</span>&lt;<span class="class"><span class="keyword">class</span> <span class="title">T</span>&gt;</span></span><br><span class="line"><span class="class"> <span class="title">void</span> <span class="title">swap</span>(<span class="title">T</span>&amp; <span class="title">a</span>, <span class="title">T</span>&amp; <span class="title">b</span>) </span></span><br><span class="line"><span class="class"> &#123;</span></span><br><span class="line">   <span class="function">T <span class="title">tmp</span><span class="params">(a)</span></span>;</span><br><span class="line">   a = b; <span class="comment">// copy</span></span><br><span class="line">   b = tmp;</span><br><span class="line"> &#125;</span><br></pre></td></tr></table></figure>

<figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">template</span>&lt;<span class="class"><span class="keyword">class</span> <span class="title">T</span>&gt;</span></span><br><span class="line"><span class="class">  <span class="title">void</span> <span class="title">swap</span>(<span class="title">T</span>&amp; <span class="title">a</span>,<span class="title">T</span>&amp; <span class="title">b</span>)</span></span><br><span class="line"><span class="class">&#123;</span></span><br><span class="line">  <span class="function">T <span class="title">tmp</span><span class="params">(<span class="built_in">std</span>::move(a))</span></span>;</span><br><span class="line">  a = <span class="built_in">std</span>::move(b); <span class="comment">// move</span></span><br><span class="line">  b = <span class="built_in">std</span>::move(tmp);</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h4 id="使用右值引用精确传递"><a href="#使用右值引用精确传递" class="headerlink" title="使用右值引用精确传递"></a>使用右值引用精确传递</h4><figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">template</span>&lt;<span class="keyword">typename</span> T&gt;</span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">forward_value</span><span class="params">(<span class="keyword">const</span> T&amp; val)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">	process_value(val);  </span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="keyword">template</span>&lt;<span class="keyword">typename</span> T&gt;</span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">forward_value</span><span class="params">(T&amp; val)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">  process_value(val);  </span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="keyword">int</span> a = <span class="number">0</span>; </span><br><span class="line"><span class="keyword">const</span> <span class="keyword">int</span> &amp;b = <span class="number">1</span>; </span><br><span class="line"><span class="comment">// 为了实现const T&amp; 和T&amp;必须重载</span></span><br><span class="line">forward_value(a); <span class="comment">// int&amp; </span></span><br><span class="line">forward_value(b); <span class="comment">// const int&amp; </span></span><br><span class="line">forward_value(<span class="number">2</span>); <span class="comment">// int&amp;</span></span><br></pre></td></tr></table></figure>

<p>为了解决这种情况，使用右值引用</p>
<figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">template</span>&lt;<span class="keyword">typename</span> T&gt;</span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">forward_value</span><span class="params">(T&amp;&amp; val)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">  process_value(val);</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h4 id="智能指针"><a href="#智能指针" class="headerlink" title="智能指针"></a>智能指针</h4><p>智能指针在C++11版本之后提供，包含在头文件<memory>中，shared_ptr、unique_ptr、weak_ptr</memory></p>
<h5 id="shared-ptr"><a href="#shared-ptr" class="headerlink" title="shared_ptr"></a>shared_ptr</h5><p>shared_ptr多个指针指向相同的对象。shared_ptr使用引用计数，每一个shared_ptr的拷贝都指向相同的内存。每使用他一次，内部的引用计数加1，每析构一次，内部的引用计数减1，减为0时，自动删除所指向的堆内存。shared_ptr内部的引用计数是线程安全的，但是对象的读取需要加锁。</p>
<ul>
<li>初始化。智能指针是个模板类，可以指定类型，传入指针通过构造函数初始化。也可以使用make_shared函数初始化。不能将指针直接赋值给一个智能指针，一个是类，一个是指针。例如std::shared_ptr<int> p4 = new int(1);的写法是错误的</int></li>
<li>拷贝和赋值。拷贝使得对象的引用计数增加1，赋值使得原对象引用计数减1，当计数为0时，自动释放内存。后来指向的对象引用计数加1，指向后来的对象。</li>
<li>get函数获取原始指针</li>
<li>注意不要用一个原始指针初始化多个shared_ptr，否则会造成二次释放同一内存</li>
<li><strong>注意避免循环引用</strong>，shared_ptr的一个最大的陷阱是循环引用，循环，循环引用会导致堆内存无法正确释放，导致内存泄漏。循环引用在weak_ptr中介绍。</li>
</ul>
<h5 id="unique-ptr"><a href="#unique-ptr" class="headerlink" title="unique_ptr"></a>unique_ptr</h5><p>unique_ptr“唯一”拥有其所指对象，同一时刻只能有一个unique_ptr指向给定对象（通过禁止拷贝语义、只有移动语义来实现）,unique_ptr指针与其所指对象的关系：在智能指针生命周期内，可以改变智能指针所指对象，如创建智能指针时通过构造函数指定、通过reset方法重新指定、通过release方法释放所有权、通过移动语义转移所有权。</p>
<figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;iostream&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;memory&gt;</span></span></span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">int</span> <span class="title">main</span><span class="params">()</span> </span>&#123;</span><br><span class="line">    &#123;</span><br><span class="line">        <span class="built_in">std</span>::<span class="built_in">unique_ptr</span>&lt;<span class="keyword">int</span>&gt; uptr(<span class="keyword">new</span> <span class="keyword">int</span>(<span class="number">10</span>));  <span class="comment">//绑定动态对象</span></span><br><span class="line">        <span class="comment">//std::unique_ptr&lt;int&gt; uptr2 = uptr;  //不能賦值</span></span><br><span class="line">        <span class="comment">//std::unique_ptr&lt;int&gt; uptr2(uptr);  //不能拷貝</span></span><br><span class="line">        <span class="built_in">std</span>::<span class="built_in">unique_ptr</span>&lt;<span class="keyword">int</span>&gt; uptr2 = <span class="built_in">std</span>::move(uptr); <span class="comment">//轉換所有權</span></span><br><span class="line">        uptr2.release(); <span class="comment">//释放所有权</span></span><br><span class="line">    &#125;</span><br><span class="line">    <span class="comment">//超過uptr的作用域，內存釋放</span></span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h5 id="weak-ptr"><a href="#weak-ptr" class="headerlink" title="weak_ptr"></a>weak_ptr</h5><p>weak_ptr是为了配合shared_ptr而引入的一种智能指针，因为它不具有普通指针的行为，没有重载operator*和-&gt;,它的最大作用在于协助shared_ptr工作，像旁观者那样观测资源的使用情况。</p>
<p>weak_ptr可以从一个shared_ptr或者另一个weak_ptr对象构造，获得资源的观测权。但weak_ptr没有共享资源，它的构造不会引起指针引用计数的增加。</p>
<p>使用weak_ptr的成员函数use_count()可以观测资源的引用计数，另一个成员函数expired()的功能等价于use_count()==0,但更快，表示被观测的资源(也就是shared_ptr的管理的资源)已经不复存在。weak_ptr可以使用一个非常重要的成员函数lock()从被观测的shared_ptr获得一个可用的shared_ptr对象， 从而操作资源。但当expired()==true的时候，lock()函数将返回一个存储空指针的shared_ptr。</p>
<figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;iostream&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;memory&gt;</span></span></span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">int</span> <span class="title">main</span><span class="params">()</span> </span>&#123;</span><br><span class="line">    &#123;</span><br><span class="line">        <span class="built_in">std</span>::<span class="built_in">shared_ptr</span>&lt;<span class="keyword">int</span>&gt; sh_ptr = <span class="built_in">std</span>::make_shared&lt;<span class="keyword">int</span>&gt;(<span class="number">10</span>);</span><br><span class="line">        <span class="built_in">std</span>::<span class="built_in">cout</span> &lt;&lt; sh_ptr.use_count() &lt;&lt; <span class="built_in">std</span>::<span class="built_in">endl</span>; <span class="comment">// 1</span></span><br><span class="line"></span><br><span class="line">        <span class="built_in">std</span>::weak_ptr&lt;<span class="keyword">int</span>&gt; wp(sh_ptr);</span><br><span class="line">        <span class="built_in">std</span>::<span class="built_in">cout</span> &lt;&lt; wp.use_count() &lt;&lt; <span class="built_in">std</span>::<span class="built_in">endl</span>; <span class="comment">// 1</span></span><br><span class="line"></span><br><span class="line">        <span class="keyword">if</span>(!wp.expired())&#123;</span><br><span class="line">            <span class="built_in">std</span>::<span class="built_in">shared_ptr</span>&lt;<span class="keyword">int</span>&gt; sh_ptr2 = wp.lock(); <span class="comment">//get another shared_ptr</span></span><br><span class="line">            *sh_ptr = <span class="number">100</span>;</span><br><span class="line">            <span class="built_in">std</span>::<span class="built_in">cout</span> &lt;&lt; wp.use_count() &lt;&lt; <span class="built_in">std</span>::<span class="built_in">endl</span>; <span class="comment">// 2</span></span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="comment">//delete memory</span></span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h4 id="std-function"><a href="#std-function" class="headerlink" title="std::function"></a>std::function</h4><ul>
<li><p>std::function 是一个可调用对象包装器，是一个类模板，可以容纳除了类成员函数指针之外的所有可调用对象，它可以用统一的方式处理函数、函数对象、函数指针，并允许保存和延迟它们的执行。</p>
</li>
<li><p>定义格式：std::function&lt;函数类型&gt;。</p>
</li>
<li><p>std::function可以取代函数指针的作用，因为它可以延迟函数的执行，特别适合作为回调函数使用。它比普通函数指针更加的灵活和便利。</p>
</li>
</ul>
<h4 id="std-bind"><a href="#std-bind" class="headerlink" title="std::bind"></a>std::bind</h4><p>可将std::bind函数看作一个<strong>通用的函数适配器</strong>，它接受一个可调用对象，生成一个新的可调用对象来“适应”原对象的参数列表。</p>
<p>std::bind将可调用对象与其参数一起进行绑定，绑定后的结果可以使用std::function保存。std::bind主要有以下两个作用：</p>
<ul>
<li><p>将可调用对象和其参数绑定成一个防函数；</p>
</li>
<li><p>只绑定部分参数，减少可调用对象传入的参数。</p>
<p><strong>注意：</strong></p>
</li>
<li><p>（1）bind预先绑定的参数需要传具体的变量或值进去，对于预先绑定的参数，是pass-by-value的</p>
</li>
<li><p>（2）对于不事先绑定的参数，需要传std::placeholders进去，从_1开始，依次递增。placeholder是pass-by-reference的</p>
</li>
<li><p>（3）bind的返回值是可调用实体，可以直接赋给std::function对象</p>
</li>
<li><p>（4）对于绑定的指针、引用类型的参数，使用者需要保证在可调用实体调用之前，这些参数是可用的</p>
</li>
<li><p>（5）<strong>类的this可以通过对象或者指针来绑定</strong></p>
</li>
</ul>
<figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="keyword">int</span> <span class="title">Func</span><span class="params">(<span class="keyword">int</span> x, <span class="keyword">int</span> y)</span></span>;</span><br><span class="line"><span class="keyword">auto</span> bf1 = <span class="built_in">std</span>::bind(Func, <span class="number">10</span>, <span class="built_in">std</span>::placeholders::_1);</span><br><span class="line">bf1(<span class="number">20</span>); <span class="comment">///&lt; same as Func(10, 20)</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">int</span> HelloWorld::AddFunc( <span class="keyword">int</span> a, <span class="keyword">int</span> b )</span><br><span class="line">&#123;</span><br><span class="line"><span class="keyword">return</span> a + b;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="keyword">bool</span> HelloWorld::init()</span><br><span class="line">&#123;</span><br><span class="line"></span><br><span class="line"><span class="keyword">auto</span> bf2 = <span class="built_in">std</span>::bind(&amp;HelloWorld::AddFunc,<span class="keyword">this</span> , <span class="built_in">std</span>::placeholders::_1, <span class="built_in">std</span>::placeholders::_2 );</span><br><span class="line"><span class="keyword">auto</span> result1 = bf2(<span class="number">10</span>, <span class="number">20</span>); <span class="comment">///&lt; same as a.Func(10, 20)</span></span><br><span class="line"></span><br><span class="line"><span class="built_in">std</span>::function&lt; <span class="keyword">int</span>(<span class="keyword">int</span>)&gt; bf3 = <span class="built_in">std</span>::bind(&amp;HelloWorld::AddFunc, <span class="keyword">this</span>, <span class="built_in">std</span>::placeholders::_1, <span class="number">100</span>);</span><br><span class="line"><span class="keyword">auto</span> result2 = bf3(<span class="number">10</span>); <span class="comment">///&lt; same as a.Func(10, 100)</span></span><br><span class="line"></span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>



<figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="keyword">double</span> <span class="title">my_divide</span> <span class="params">(<span class="keyword">double</span> x, <span class="keyword">double</span> y)</span> </span>&#123;<span class="keyword">return</span> x/y;&#125;</span><br><span class="line"><span class="comment">// bind的第一个参数是函数名，普通函数做实参时，会隐式转换成函数指针，因此std::bind (my_divide,_1,2)等价于std::bind (&amp;my_divide,_1,2)；</span></span><br><span class="line"><span class="keyword">auto</span> fn_half = <span class="built_in">std</span>::bind (my_divide,_1,<span class="number">2</span>);   <span class="comment">//减少参数，_1表示占位符，位于&lt;functional&gt;中，std::placeholders::_1；</span></span><br><span class="line"><span class="built_in">std</span>::<span class="built_in">cout</span> &lt;&lt; fn_half(<span class="number">10</span>) &lt;&lt; <span class="string">'\n'</span>;</span><br></pre></td></tr></table></figure>

<figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line"><span class="class"><span class="keyword">struct</span> <span class="title">Foo</span> &#123;</span></span><br><span class="line">    <span class="function"><span class="keyword">void</span> <span class="title">print_sum</span><span class="params">(<span class="keyword">int</span> n1, <span class="keyword">int</span> n2)</span></span></span><br><span class="line"><span class="function">    </span>&#123;</span><br><span class="line">        <span class="built_in">std</span>::<span class="built_in">cout</span> &lt;&lt; n1+n2 &lt;&lt; <span class="string">'\n'</span>;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">int</span> data = <span class="number">10</span>;</span><br><span class="line">&#125;;</span><br><span class="line"><span class="function"><span class="keyword">int</span> <span class="title">main</span><span class="params">()</span> </span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    Foo foo;</span><br><span class="line">    <span class="comment">// bind绑定类成员函数时，第一个参数表示对象的成员函数的指针，第二个参数表示对象的地址。</span></span><br><span class="line">    <span class="keyword">auto</span> f = <span class="built_in">std</span>::bind(&amp;Foo::print_sum, &amp;foo, <span class="number">95</span>, <span class="built_in">std</span>::placeholders::_1);</span><br><span class="line">    f(<span class="number">5</span>); <span class="comment">// 100</span></span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h4 id="std-forward"><a href="#std-forward" class="headerlink" title="std::forward"></a>std::forward</h4><p>需要一种方法能<strong>够按照参数原来的类型转</strong>发到另一个函数，这种转发类型称为<strong>完美转发</strong>。</p>
<p>完美转发（Perfect Forwarding），是指在函数模板中，完全依照模板的参数的类型（即保持参数的左值、右值特征），将参数传递给函数模板中调用的另外一个函数。C++11中提供了这样的一个函数std::forward，它是为转发而生的，不管参数是T&amp;&amp;这种未定的引用还是明确的左值引用或者右值引用，它会按照参数本来的类型转发。</p>
<figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span><span class="meta-string">&lt;iostream&gt;</span></span></span><br><span class="line"><span class="keyword">using</span> <span class="keyword">namespace</span> <span class="built_in">std</span>;</span><br><span class="line"><span class="keyword">template</span>&lt;<span class="keyword">typename</span> T&gt;</span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">print</span><span class="params">(T&amp; t)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    <span class="built_in">cout</span> &lt;&lt; <span class="string">"lvalue"</span> &lt;&lt; <span class="built_in">endl</span>;</span><br><span class="line">&#125;</span><br><span class="line"> </span><br><span class="line"><span class="keyword">template</span>&lt;<span class="keyword">typename</span> T&gt;</span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">print</span><span class="params">(T&amp;&amp; t)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    <span class="built_in">cout</span> &lt;&lt; <span class="string">"rvalue"</span> &lt;&lt; <span class="built_in">endl</span>;</span><br><span class="line">&#125;</span><br><span class="line"> </span><br><span class="line"><span class="keyword">template</span>&lt;<span class="keyword">typename</span> T&gt;</span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">TestForward</span><span class="params">(T &amp;&amp; v)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    <span class="comment">//print(v); //编译错误  不知道是哪个print</span></span><br><span class="line">    print(<span class="built_in">std</span>::forward&lt;T&gt;(v));</span><br><span class="line">    print(<span class="built_in">std</span>::move(v));</span><br><span class="line">&#125;</span><br><span class="line"> </span><br><span class="line"><span class="function"><span class="keyword">int</span> <span class="title">main</span><span class="params">()</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    TestForward(<span class="number">1</span>);</span><br><span class="line">    <span class="keyword">int</span> x = <span class="number">1</span>;</span><br><span class="line">    <span class="comment">//TestForward(x); //使print(std::forward&lt;T&gt;(v));编译错误</span></span><br><span class="line">    TestForward(<span class="built_in">std</span>::forward&lt;<span class="keyword">int</span>&gt;(x));</span><br><span class="line">    <span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">&#125;</span><br><span class="line"><span class="comment">//rvalue</span></span><br><span class="line"><span class="comment">//rvalue</span></span><br><span class="line"><span class="comment">//rvalue</span></span><br><span class="line"><span class="comment">//rvalue</span></span><br></pre></td></tr></table></figure>

<p>std::move没有move任何东西，std::forward没有转发任何东西。在运行期，它们没有做任何事情。它们没有产生需要执行的代码，一byte都没有。</p>
<p>std::move和std::forward只不过就是执行cast的两个函数（实际上是函数模板）。<strong>std::move无条件地把它的参数转换成一个右值，而std::forward只在特定条件满足的情况下执行这个转换。</strong></p>
<h4 id="delete"><a href="#delete" class="headerlink" title="delete"></a>delete</h4><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">为了能够让程序员显式的禁用某个函数，C++11 标准引入了一个新特性：&quot;=delete&quot;函数。程序员只需在函数声明后上“=delete;”，就可将该函数禁用。</span><br></pre></td></tr></table></figure>

<figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="class"><span class="keyword">class</span> <span class="title">MyClass</span></span></span><br><span class="line"><span class="class">&#123;</span></span><br><span class="line">  <span class="keyword">public</span>:</span><br><span class="line">    MyClass()=<span class="keyword">default</span>;  <span class="comment">//该函数比用户自己定义的默认构造函数获得更高的代码效率</span></span><br><span class="line">    MyClass(<span class="keyword">const</span> MyClass&amp; )=<span class="keyword">delete</span>;</span><br><span class="line">  ......</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h4 id="enable-shared-from-this"><a href="#enable-shared-from-this" class="headerlink" title="enable_shared_from_this"></a>enable_shared_from_this</h4><h5 id="定义"><a href="#定义" class="headerlink" title="定义"></a>定义</h5><p>std::enable_shared_from_this 能让一个对象（假设其名为 t ，且已被一个 std::shared_ptr 对象 pt 管理）安全地生成其他额外的 std::shared_ptr 实例（假设名为 pt1, pt2, … ） ，它们与 pt 共享对象 t 的所有权。</p>
<p>若一个类 T 继承 std::enable_shared_from_this<t> ，则会为该类 T 提供成员函数： shared_from_this 。 当 T 类型对象 t 被一个为名为 pt 的 std::shared_ptr<t> 类对象管理时，调用 T::shared_from_this 成员函数，将会返回一个新的 std::shared_ptr<t> 对象，它与 pt 共享 t 的所有权。</t></t></t></p>
<h5 id="使用场合"><a href="#使用场合" class="headerlink" title="使用场合"></a>使用场合</h5><p>当类A被share_ptr管理，且在类A的成员函数里需要把当前类对象作为参数传给其他函数时，就需要传递一个指向自身的share_ptr。</p>
<ol>
<li>为何不直接传递this指针</li>
</ol>
<p>​        使用智能指针的初衷就是为了方便资源管理，如果在某些地方使用智能指针，某些地方使用原始指针，很容易破坏智能指针的语义，从而产生各种错误。</p>
<ol start="2">
<li><p>可以直接传递share_ptr<this>么？</this></p>
<p> 答案是不能，因为这样会造成2个非共享的share_ptr指向同一个对象，未增加引用计数导对象被析构两次。</p>
<p>错误：</p>
<figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;memory&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;iostream&gt;</span></span></span><br><span class="line"> </span><br><span class="line"><span class="class"><span class="keyword">class</span> <span class="title">Bad</span></span></span><br><span class="line"><span class="class">&#123;</span></span><br><span class="line"><span class="keyword">public</span>:</span><br><span class="line">	<span class="built_in">std</span>::<span class="built_in">shared_ptr</span>&lt;Bad&gt; getptr() &#123;</span><br><span class="line">		<span class="keyword">return</span> <span class="built_in">std</span>::<span class="built_in">shared_ptr</span>&lt;Bad&gt;(<span class="keyword">this</span>);</span><br><span class="line">	&#125;</span><br><span class="line">	~Bad() &#123; <span class="built_in">std</span>::<span class="built_in">cout</span> &lt;&lt; <span class="string">"Bad::~Bad() called"</span> &lt;&lt; <span class="built_in">std</span>::<span class="built_in">endl</span>; &#125;</span><br><span class="line">&#125;;</span><br><span class="line"> </span><br><span class="line"><span class="function"><span class="keyword">int</span> <span class="title">main</span><span class="params">()</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">	<span class="comment">// 错误的示例，每个shared_ptr都认为自己是对象仅有的所有者</span></span><br><span class="line">	<span class="built_in">std</span>::<span class="built_in">shared_ptr</span>&lt;Bad&gt; bp1(<span class="keyword">new</span> Bad());</span><br><span class="line">	<span class="built_in">std</span>::<span class="built_in">shared_ptr</span>&lt;Bad&gt; bp2 = bp1-&gt;getptr();</span><br><span class="line">	<span class="comment">// 打印bp1和bp2的引用计数</span></span><br><span class="line">	<span class="built_in">std</span>::<span class="built_in">cout</span> &lt;&lt; <span class="string">"bp1.use_count() = "</span> &lt;&lt; bp1.use_count() &lt;&lt; <span class="built_in">std</span>::<span class="built_in">endl</span>;</span><br><span class="line">	<span class="built_in">std</span>::<span class="built_in">cout</span> &lt;&lt; <span class="string">"bp2.use_count() = "</span> &lt;&lt; bp2.use_count() &lt;&lt; <span class="built_in">std</span>::<span class="built_in">endl</span>;</span><br><span class="line">&#125;  <span class="comment">// Bad 对象将会被删除两次</span></span><br></pre></td></tr></table></figure>

<p>正确：</p>
<figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;memory&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;iostream&gt;</span></span></span><br><span class="line"> </span><br><span class="line"><span class="class"><span class="keyword">struct</span> <span class="title">Good</span> :</span> <span class="built_in">std</span>::enable_shared_from_this&lt;Good&gt; <span class="comment">// 注意：继承</span></span><br><span class="line">&#123;</span><br><span class="line"><span class="keyword">public</span>:</span><br><span class="line">	<span class="built_in">std</span>::<span class="built_in">shared_ptr</span>&lt;Good&gt; getptr() &#123;</span><br><span class="line">		<span class="keyword">return</span> shared_from_this();</span><br><span class="line">	&#125;</span><br><span class="line">	~Good() &#123; <span class="built_in">std</span>::<span class="built_in">cout</span> &lt;&lt; <span class="string">"Good::~Good() called"</span> &lt;&lt; <span class="built_in">std</span>::<span class="built_in">endl</span>; &#125;</span><br><span class="line">&#125;;</span><br><span class="line"> </span><br><span class="line"><span class="function"><span class="keyword">int</span> <span class="title">main</span><span class="params">()</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">	<span class="comment">// 大括号用于限制作用域，这样智能指针就能在system("pause")之前析构</span></span><br><span class="line">	&#123;</span><br><span class="line">		<span class="built_in">std</span>::<span class="built_in">shared_ptr</span>&lt;Good&gt; gp1(<span class="keyword">new</span> Good());</span><br><span class="line">		<span class="built_in">std</span>::<span class="built_in">shared_ptr</span>&lt;Good&gt; gp2 = gp1-&gt;getptr();</span><br><span class="line">		<span class="comment">// 打印gp1和gp2的引用计数</span></span><br><span class="line">		<span class="built_in">std</span>::<span class="built_in">cout</span> &lt;&lt; <span class="string">"gp1.use_count() = "</span> &lt;&lt; gp1.use_count() &lt;&lt; <span class="built_in">std</span>::<span class="built_in">endl</span>;</span><br><span class="line">		<span class="built_in">std</span>::<span class="built_in">cout</span> &lt;&lt; <span class="string">"gp2.use_count() = "</span> &lt;&lt; gp2.use_count() &lt;&lt; <span class="built_in">std</span>::<span class="built_in">endl</span>;</span><br><span class="line">	&#125;</span><br><span class="line">	system(<span class="string">"pause"</span>);</span><br></pre></td></tr></table></figure>

<p><strong>为何会出现这种使用场合</strong></p>
<p>​        因为在异步调用中，存在一个保活机制，异步函数执行的时间点我们是无法确定的，然而异步函数可能会使用到异步调用之前就存在的变量。为了保证该变量在异步函数执期间一直有效，我们可以传递一个指向自身的share_ptr给异步函数，这样在异步函数执行期间share_ptr所管理的对象就不会析构，所使用的变量也会一直有效了（保活）。</p>
</li>
</ol>
<h4 id="mutable"><a href="#mutable" class="headerlink" title="mutable"></a>mutable</h4><p>在C++中，<strong>mutable</strong>也是为了突破const的限制而设置的。被<strong>mutable</strong>修饰的变量，将永远处于可变的状态，即使在一个const函数中。</p>
<p>我们知道，被const关键字修饰的函数的一个重要作用就是为了能够保护类中的成员变量。即：该函数可以使用类中的所有成员变量，但是不能修改他们的值。然而，在某些特殊情况下，我们还是需要在const函数中修改类的某些成员变量，因为要修改的成员变量与类本身并无多少关系，即使修改了也不会对类造成多少影响。当然，你可以说，你可以去掉该函数的const关键字呀！但问题是，我只想修改某个成员变量，其余成员变量仍然希望被const保护。</p>
<h4 id="using各种用法"><a href="#using各种用法" class="headerlink" title="using各种用法"></a>using各种用法</h4><figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/*定义别名*/</span></span><br><span class="line"> <span class="keyword">template</span>&lt;<span class="class"><span class="keyword">class</span> <span class="title">T</span>&gt;</span></span><br><span class="line"><span class="class"> <span class="title">using</span> <span class="title">Tlist</span> = <span class="title">std</span>:</span>:<span class="built_in">list</span>&lt;T&gt;;</span><br><span class="line"> </span><br><span class="line"> <span class="keyword">using</span> Tlist = <span class="built_in">std</span>::<span class="built_in">list</span>&lt;<span class="keyword">char</span>&gt;;</span><br><span class="line"> Tlist listChar;</span><br><span class="line"> </span><br><span class="line"> <span class="comment">//typedef void (*df)()</span></span><br><span class="line">  <span class="keyword">using</span>  df = <span class="keyword">void</span>(*)();</span><br><span class="line"> <span class="comment">/*使用外部构造*/</span></span><br><span class="line"> <span class="keyword">using</span> A::A;</span><br><span class="line"> </span><br><span class="line"> <span class="comment">/*引用外部类型*/</span></span><br><span class="line"><span class="keyword">using</span> <span class="keyword">typename</span> A;</span><br></pre></td></tr></table></figure>

<p>不想要使用默认的拷贝构造函数或赋值函数</p>
<p>1.新增auto、decltype关键字，二者相似又有区别<br>　　2.新增char16_t、char32_t、long long int类型<br>　　3.新增constexpr编译时常量表达式<br>　　4.新增default、delete、override、final说明符<br>　　5.新增delegating constructors委托构造函数<br>　　6.新增std::initializer_list初始化列表、uniform initialization统一初始化</p>
<p>　　7.新增Enum class枚举类、extend templates拓展模板、type可用于模板<br>　　8.新增Lambda表达式<br>　　9.新增nullptr、foreach、r-value右值，tuple元组<br>　　10.新增移动意义，包括move constructor移动构造、move assign移动赋值<br>　　11.新增static_assert编译时检查<br>　　12.新增智能指针std::unique_ptr、std::share_ptr、std::weak_ptr，废弃std::auto_ptr</p>
<p>C++14新特性：</p>
<p>　　1.新增聚合成员初始化<br>　　2.新增二进制文字、数字分隔符<br>　　3.废弃attribute<br>　　4.新增函数返回值推断<br>　　5.新增constexpr函数<br>　　6.新增变体模板<br>　　7.新增标准用户定义的文字<br>　　8.新增std::make_unique，用于创建std::unique_ptr、</p>
<h3 id="参考信息"><a href="#参考信息" class="headerlink" title="参考信息"></a>参考信息</h3><table>
<thead>
<tr>
<th align="left">C++2a 功能特性</th>
<th align="left">提案</th>
<th align="left">版本</th>
<th align="left">GCC</th>
<th align="left">Clang</th>
<th align="left">MSVC</th>
<th align="left">EDG eccp</th>
<th align="left">Intel C++</th>
<th align="left">IBM XLC++</th>
<th align="left">Sun/Oracle C++</th>
<th align="left">Embarcadero C++ Builder</th>
<th align="left">Cray</th>
<th align="left">Portland Group (PGI)</th>
<th align="left">[<a href="https://zh.cppreference.com/w/cpp/compiler_support#" target="_blank" rel="noopener">折叠</a>]</th>
</tr>
</thead>
<tbody><tr>
<td align="left">允许 lambda 捕获 <code>[=, this]</code></td>
<td align="left"><a href="https://wg21.link/P0409R2" target="_blank" rel="noopener">P0409R2</a></td>
<td align="left">c++2a-lang</td>
<td align="left">8</td>
<td align="left">6</td>
<td align="left"></td>
<td align="left">5.1</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
</tr>
<tr>
<td align="left"><code>__VA_OPT__</code></td>
<td align="left"><a href="https://wg21.link/P0306R4" target="_blank" rel="noopener">P0306R4</a></td>
<td align="left">c++2a-lang</td>
<td align="left">8 (部分)*</td>
<td align="left">6</td>
<td align="left"></td>
<td align="left">5.1</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
</tr>
<tr>
<td align="left"><a href="https://zh.cppreference.com/w/cpp/language/aggregate_initialization#.E6.8C.87.E6.B4.BE.E5.88.9D.E5.A7.8B.E5.8C.96.E5.99.A8" target="_blank" rel="noopener">指派初始化器</a></td>
<td align="left"><a href="https://wg21.link/P0329R4" target="_blank" rel="noopener">P0329R4</a></td>
<td align="left">c++2a-lang</td>
<td align="left">4.7 (部分)* 8</td>
<td align="left">3.0 (部分)*</td>
<td align="left"></td>
<td align="left">5.1</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
</tr>
<tr>
<td align="left">泛型 lambda 的模板形参列表</td>
<td align="left"><a href="https://wg21.link/P0428R2" target="_blank" rel="noopener">P0428R2</a></td>
<td align="left">c++2a-lang</td>
<td align="left">8</td>
<td align="left"></td>
<td align="left"></td>
<td align="left">5.1</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
</tr>
<tr>
<td align="left">位域的默认成员初始化器</td>
<td align="left"><a href="https://wg21.link/P0683R1" target="_blank" rel="noopener">P0683R1</a></td>
<td align="left">c++2a-lang</td>
<td align="left">8</td>
<td align="left">6</td>
<td align="left"></td>
<td align="left">5.1</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
</tr>
<tr>
<td align="left">类模板实参推导中的 initializer_list 构造函数</td>
<td align="left"><a href="https://wg21.link/P0702R1" target="_blank" rel="noopener">P0702R1</a></td>
<td align="left">c++2a-lang</td>
<td align="left">8</td>
<td align="left">6</td>
<td align="left">19.14*</td>
<td align="left">5.0</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
</tr>
<tr>
<td align="left">const&amp; 限定的成员指针</td>
<td align="left"><a href="https://wg21.link/P0704R1" target="_blank" rel="noopener">P0704R1</a></td>
<td align="left">c++2a-lang</td>
<td align="left">8</td>
<td align="left">6</td>
<td align="left"></td>
<td align="left">5.1</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
</tr>
<tr>
<td align="left"><a href="https://zh.cppreference.com/w/cpp/language/constraints" target="_blank" rel="noopener">概念 (concept)</a></td>
<td align="left"><a href="https://wg21.link/P0734R0" target="_blank" rel="noopener">P0734R0</a></td>
<td align="left">c++2a-lang</td>
<td align="left">6 (仅 TS)</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
</tr>
<tr>
<td align="left">不求值语境中的 lambda</td>
<td align="left"><a href="https://wg21.link/P0315R4" target="_blank" rel="noopener">P0315R4</a></td>
<td align="left">c++2a-lang</td>
<td align="left">9</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
</tr>
<tr>
<td align="left"><a href="https://zh.cppreference.com/w/cpp/language/operator_comparison#.E4.B8.89.E8.B7.AF.E6.AF.94.E8.BE.83" target="_blank" rel="noopener">三路比较运算符</a></td>
<td align="left"><a href="https://wg21.link/P0515R3" target="_blank" rel="noopener">P0515R3</a></td>
<td align="left">c++2a-lang</td>
<td align="left"></td>
<td align="left">8 (部分)*</td>
<td align="left">19.20*</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
</tr>
<tr>
<td align="left">简化隐式 lambda 捕获</td>
<td align="left"><a href="https://wg21.link/P0588R1" target="_blank" rel="noopener">P0588R1</a></td>
<td align="left">c++2a-lang</td>
<td align="left">8</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
</tr>
<tr>
<td align="left">基于范围的 for 的初始化语句</td>
<td align="left"><a href="https://wg21.link/P0614R1" target="_blank" rel="noopener">P0614R1</a></td>
<td align="left">c++2a-lang</td>
<td align="left">9</td>
<td align="left">8</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
</tr>
<tr>
<td align="left">可默认构造且可赋值的无状态 lambda</td>
<td align="left"><a href="https://wg21.link/P0624R2" target="_blank" rel="noopener">P0624R2</a></td>
<td align="left">c++2a-lang</td>
<td align="left">9</td>
<td align="left">8</td>
<td align="left"></td>
<td align="left">5.1</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
</tr>
<tr>
<td align="left">与预置的复制构造函数的 const 不匹配</td>
<td align="left"><a href="https://wg21.link/P0641R2" target="_blank" rel="noopener">P0641R2</a></td>
<td align="left">c++2a-lang</td>
<td align="left">9</td>
<td align="left">8</td>
<td align="left"></td>
<td align="left">5.1</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
</tr>
<tr>
<td align="left">特化上的访问检查</td>
<td align="left"><a href="https://wg21.link/P0692R1" target="_blank" rel="noopener">P0692R1</a></td>
<td align="left">c++2a-lang</td>
<td align="left">是</td>
<td align="left">8 (部分)*</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
</tr>
<tr>
<td align="left">ADL 与不可见的函数模板</td>
<td align="left"><a href="https://wg21.link/P0846R0" target="_blank" rel="noopener">P0846R0</a></td>
<td align="left">c++2a-lang</td>
<td align="left">9</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
</tr>
<tr>
<td align="left">令 constexpr 函数的实例化较不贪婪</td>
<td align="left"><a href="https://wg21.link/P0859R0" target="_blank" rel="noopener">P0859R0</a></td>
<td align="left">c++2a-lang</td>
<td align="left">5.2 (部分)* 9</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
</tr>
<tr>
<td align="left">属性 <code>[[likely]]</code> 与 <code>[[unlikely]]</code></td>
<td align="left"><a href="https://wg21.link/P0479R5" target="_blank" rel="noopener">P0479R5</a></td>
<td align="left">c++2a-lang</td>
<td align="left">9</td>
<td align="left"></td>
<td align="left"></td>
<td align="left">5.1</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
</tr>
<tr>
<td align="left">使 <code>typename</code> 更可选</td>
<td align="left"><a href="https://wg21.link/P0634R3" target="_blank" rel="noopener">P0634R3</a></td>
<td align="left">c++2a-lang</td>
<td align="left">9</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
</tr>
<tr>
<td align="left">Lambda 初始化捕获中的包展开</td>
<td align="left"><a href="https://wg21.link/P0780R2" target="_blank" rel="noopener">P0780R2</a></td>
<td align="left">c++2a-lang</td>
<td align="left">9</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
</tr>
<tr>
<td align="left">属性 <code>[[no_unique_address]]</code></td>
<td align="left"><a href="https://wg21.link/P0840R2" target="_blank" rel="noopener">P0840R2</a></td>
<td align="left">c++2a-lang</td>
<td align="left">9</td>
<td align="left"></td>
<td align="left"></td>
<td align="left">5.1</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
</tr>
<tr>
<td align="left"><a href="https://zh.cppreference.com/w/cpp/language/attributes/contract" target="_blank" rel="noopener">契约</a></td>
<td align="left"><a href="https://wg21.link/P0542R5" target="_blank" rel="noopener">P0542R5</a></td>
<td align="left">c++2a-lang</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
</tr>
<tr>
<td align="left"><a href="https://zh.cppreference.com/w/cpp/memory/new/operator_delete" target="_blank" rel="noopener">销毁的 operator delete</a></td>
<td align="left"><a href="https://wg21.link/P0722R3" target="_blank" rel="noopener">P0722R3</a></td>
<td align="left">c++2a-lang</td>
<td align="left">9</td>
<td align="left">6</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
</tr>
<tr>
<td align="left">非类型模板形参中的类类型</td>
<td align="left"><a href="https://wg21.link/P0732R2" target="_blank" rel="noopener">P0732R2</a></td>
<td align="left">c++2a-lang</td>
<td align="left">9</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
</tr>
<tr>
<td align="left"><a href="https://zh.cppreference.com/w/cpp/language/explicit" target="_blank" rel="noopener">explicit(bool)</a></td>
<td align="left"><a href="https://wg21.link/P0892R2" target="_blank" rel="noopener">P0892R2</a></td>
<td align="left">c++2a-lang</td>
<td align="left">9</td>
<td align="left"></td>
<td align="left"></td>
<td align="left">5.1</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
</tr>
<tr>
<td align="left">整合功能特性测试宏</td>
<td align="left"><a href="https://wg21.link/P0941R2" target="_blank" rel="noopener">P0941R2</a></td>
<td align="left">c++2a-lang</td>
<td align="left">5</td>
<td align="left">3.4</td>
<td align="left">19.15*</td>
<td align="left">5.0</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
</tr>
<tr>
<td align="left">禁止聚合体有用户声明的构造函数</td>
<td align="left"><a href="https://wg21.link/P1008R1" target="_blank" rel="noopener">P1008R1</a></td>
<td align="left">c++2a-lang</td>
<td align="left">9</td>
<td align="left">8</td>
<td align="left"></td>
<td align="left">5.1</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
</tr>
<tr>
<td align="left">constexpr 虚函数</td>
<td align="left"><a href="https://wg21.link/P1064R0" target="_blank" rel="noopener">P1064R0</a></td>
<td align="left">c++2a-lang</td>
<td align="left">9</td>
<td align="left"></td>
<td align="left"></td>
<td align="left">5.1</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
</tr>
<tr>
<td align="left"><code>char8_t</code></td>
<td align="left"><a href="https://wg21.link/P0482R6" target="_blank" rel="noopener">P0482R6</a></td>
<td align="left">c++2a-lang</td>
<td align="left">9</td>
<td align="left">7</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
</tr>
<tr>
<td align="left"><a href="https://zh.cppreference.com/w/cpp/types/is_constant_evaluated" target="_blank" rel="noopener">std::is_constant_evaluated()</a></td>
<td align="left"><a href="https://wg21.link/P0595R2" target="_blank" rel="noopener">P0595R2</a></td>
<td align="left">c++2a-lang</td>
<td align="left">9</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
</tr>
<tr>
<td align="left">constexpr <code>try</code>-<code>catch</code> 代码块</td>
<td align="left"><a href="https://wg21.link/P1002R1" target="_blank" rel="noopener">P1002R1</a></td>
<td align="left">c++2a-lang</td>
<td align="left">9</td>
<td align="left">8</td>
<td align="left"></td>
<td align="left">5.1</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
</tr>
<tr>
<td align="left"><a href="https://zh.cppreference.com/w/cpp/language/consteval" target="_blank" rel="noopener">立即函数</a></td>
<td align="left"><a href="https://wg21.link/P1073R3" target="_blank" rel="noopener">P1073R3</a></td>
<td align="left">c++2a-lang</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left">5.1</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
</tr>
<tr>
<td align="left"><a href="https://zh.cppreference.com/w/cpp/language/namespace" target="_blank" rel="noopener">嵌套内联命名空间</a></td>
<td align="left"><a href="https://wg21.link/P1094R2" target="_blank" rel="noopener">P1094R2</a></td>
<td align="left">c++2a-lang</td>
<td align="left">9</td>
<td align="left">8</td>
<td align="left"></td>
<td align="left">5.1</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
</tr>
<tr>
<td align="left">constexpr 的 <code>dynamic_cast</code> 和多态 <code>typeid</code></td>
<td align="left"><a href="https://wg21.link/P1327R1" target="_blank" rel="noopener">P1327R1</a></td>
<td align="left">c++2a-lang</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left">5.1</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
</tr>
<tr>
<td align="left">在 constexpr 中改变联合体的活跃成员</td>
<td align="left"><a href="https://wg21.link/P1330R0" target="_blank" rel="noopener">P1330R0</a></td>
<td align="left">c++2a-lang</td>
<td align="left">9</td>
<td align="left"></td>
<td align="left"></td>
<td align="left">5.1</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
</tr>
<tr>
<td align="left">结构化绑定的扩展</td>
<td align="left"><a href="https://wg21.link/P1091R3" target="_blank" rel="noopener">P1091R3</a> <a href="https://wg21.link/P1381R1" target="_blank" rel="noopener">P1381R1</a></td>
<td align="left">c++2a-lang</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
</tr>
<tr>
<td align="left">更强的 Unicode 要求</td>
<td align="left"><a href="https://wg21.link/P1041R4" target="_blank" rel="noopener">P1041R4</a> <a href="https://wg21.link/P1139R2" target="_blank" rel="noopener">P1139R2</a></td>
<td align="left">c++2a-lang</td>
<td align="left"></td>
<td align="left">是</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
</tr>
<tr>
<td align="left">参数化的聚合体初始化</td>
<td align="left"><a href="https://wg21.link/P0960R3" target="_blank" rel="noopener">P0960R3</a></td>
<td align="left">c++2a-lang</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
</tr>
<tr>
<td align="left">模块 (module)</td>
<td align="left"><a href="https://wg21.link/P1103R3" target="_blank" rel="noopener">P1103R3</a></td>
<td align="left">c++2a-lang</td>
<td align="left"></td>
<td align="left">8 (部分)</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
</tr>
<tr>
<td align="left">协程 (coroutine)</td>
<td align="left"><a href="https://wg21.link/P0912R5" target="_blank" rel="noopener">P0912R5</a></td>
<td align="left">c++2a-lang</td>
<td align="left"></td>
<td align="left">8 (部分)</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
</tr>
<tr>
<td align="left"><a href="https://zh.cppreference.com/w/cpp/types/endian" target="_blank" rel="noopener">std::endian</a></td>
<td align="left"><a href="https://wg21.link/P0463R1" target="_blank" rel="noopener">P0463R1</a></td>
<td align="left">c++2a</td>
<td align="left">8</td>
<td align="left">7</td>
<td align="left"></td>
<td align="left">N/A</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
</tr>
<tr>
<td align="left"><a href="https://zh.cppreference.com/w/cpp/types/remove_cvref" target="_blank" rel="noopener">std::remove_cvref</a></td>
<td align="left"><a href="https://wg21.link/P0550R2" target="_blank" rel="noopener">P0550R2</a></td>
<td align="left">c++2a</td>
<td align="left">9</td>
<td align="left">6</td>
<td align="left">19.20*</td>
<td align="left">N/A</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
</tr>
<tr>
<td align="left">扩展 <a href="https://zh.cppreference.com/w/cpp/memory/shared_ptr/make_shared" target="_blank" rel="noopener">std::make_shared</a> 以支持数组</td>
<td align="left"><a href="https://wg21.link/P0674R1" target="_blank" rel="noopener">P0674R1</a></td>
<td align="left">c++2a</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left">N/A</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
</tr>
<tr>
<td align="left">原子性浮点算术</td>
<td align="left"><a href="https://wg21.link/P0020R6" target="_blank" rel="noopener">P0020R6</a></td>
<td align="left">c++2a</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left">N/A</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
</tr>
<tr>
<td align="left"><a href="https://zh.cppreference.com/w/cpp/io/basic_syncbuf" target="_blank" rel="noopener">同步缓冲的</a> <a href="https://zh.cppreference.com/w/cpp/io/basic_osyncstream" target="_blank" rel="noopener">ostream</a></td>
<td align="left"><a href="https://wg21.link/P0053R7" target="_blank" rel="noopener">P0053R7</a></td>
<td align="left">c++2a</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left">N/A</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
</tr>
<tr>
<td align="left"><a href="https://zh.cppreference.com/w/cpp/header/algorithm" target="_blank" rel="noopener"></a> 与 <a href="https://zh.cppreference.com/w/cpp/header/utility" target="_blank" rel="noopener"></a> 的 <code>constexpr</code></td>
<td align="left"><a href="https://wg21.link/P0202R3" target="_blank" rel="noopener">P0202R3</a></td>
<td align="left">c++2a</td>
<td align="left"></td>
<td align="left">8</td>
<td align="left"></td>
<td align="left">N/A</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
</tr>
<tr>
<td align="left"><a href="https://zh.cppreference.com/w/cpp/header/complex" target="_blank" rel="noopener"></a> 的更多 <code>constexpr</code></td>
<td align="left"><a href="https://wg21.link/P0415R1" target="_blank" rel="noopener">P0415R1</a></td>
<td align="left">c++2a</td>
<td align="left">9</td>
<td align="left"></td>
<td align="left"></td>
<td align="left">N/A</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
</tr>
<tr>
<td align="left"><a href="https://zh.cppreference.com/w/cpp/string/basic_string" target="_blank" rel="noopener">字符串</a>前缀与后缀检查</td>
<td align="left"><a href="https://wg21.link/P0457R2" target="_blank" rel="noopener">P0457R2</a></td>
<td align="left">c++2a</td>
<td align="left">9</td>
<td align="left">6</td>
<td align="left"></td>
<td align="left">N/A</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
</tr>
<tr>
<td align="left"><code>operator&lt;=&gt;</code> 的库支持 <a href="https://zh.cppreference.com/w/cpp/header/compare" target="_blank" rel="noopener"></a></td>
<td align="left"><a href="https://wg21.link/P0515R3" target="_blank" rel="noopener">P0515R3</a></td>
<td align="left">c++2a</td>
<td align="left"></td>
<td align="left">7</td>
<td align="left">19.20*</td>
<td align="left">N/A</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
</tr>
<tr>
<td align="left">转换指针为裸指针的工具</td>
<td align="left"><a href="https://wg21.link/P0653R2" target="_blank" rel="noopener">P0653R2</a></td>
<td align="left">c++2a</td>
<td align="left">8</td>
<td align="left">6</td>
<td align="left"></td>
<td align="left">N/A</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
</tr>
<tr>
<td align="left">原子性的 <a href="https://zh.cppreference.com/w/cpp/memory/shared_ptr/atomic2" target="_blank" rel="noopener">shared_ptr</a> 与 <a href="https://zh.cppreference.com/w/cpp/memory/weak_ptr/atomic2" target="_blank" rel="noopener">weak_ptr</a></td>
<td align="left"><a href="https://wg21.link/P0718R2" target="_blank" rel="noopener">P0718R2</a></td>
<td align="left">c++2a</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left">N/A</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
</tr>
<tr>
<td align="left"><a href="https://zh.cppreference.com/w/cpp/container/span" target="_blank" rel="noopener">std::span</a></td>
<td align="left"><a href="https://wg21.link/P0122R7" target="_blank" rel="noopener">P0122R7</a></td>
<td align="left">c++2a</td>
<td align="left"></td>
<td align="left">7</td>
<td align="left"></td>
<td align="left">N/A</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
</tr>
<tr>
<td align="left"><a href="https://zh.cppreference.com/w/cpp/chrono#.E6.97.A5.E5.8E.86" target="_blank" rel="noopener">日历</a>与<a href="https://zh.cppreference.com/w/cpp/chrono#.E6.97.B6.E5.8C.BA" target="_blank" rel="noopener">时区</a></td>
<td align="left"><a href="https://wg21.link/P0355R7" target="_blank" rel="noopener">P0355R7</a></td>
<td align="left">c++2a</td>
<td align="left"></td>
<td align="left">7</td>
<td align="left"></td>
<td align="left">N/A</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
</tr>
<tr>
<td align="left"><a href="https://zh.cppreference.com/w/cpp/header/version" target="_blank" rel="noopener"></a></td>
<td align="left"><a href="https://wg21.link/P0754R2" target="_blank" rel="noopener">P0754R2</a></td>
<td align="left">c++2a</td>
<td align="left">9</td>
<td align="left">7</td>
<td align="left"></td>
<td align="left">N/A</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
</tr>
<tr>
<td align="left"><a href="https://zh.cppreference.com/w/cpp/atomic/atomic_ref" target="_blank" rel="noopener">std::atomic_ref</a></td>
<td align="left"><a href="https://wg21.link/P0019R8" target="_blank" rel="noopener">P0019R8</a></td>
<td align="left">c++2a</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left">N/A</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
</tr>
<tr>
<td align="left"><a href="https://zh.cppreference.com/w/cpp/header/bit" target="_blank" rel="noopener">整数的 2 的幂的运算</a></td>
<td align="left"><a href="https://wg21.link/P0556R3" target="_blank" rel="noopener">P0556R3</a></td>
<td align="left">c++2a</td>
<td align="left">9</td>
<td align="left"></td>
<td align="left"></td>
<td align="left">N/A</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
</tr>
<tr>
<td align="left"><a href="https://zh.cppreference.com/w/cpp/numeric/bit_cast" target="_blank" rel="noopener">std::bit_cast()</a></td>
<td align="left"><a href="https://wg21.link/P0476R2" target="_blank" rel="noopener">P0476R2</a></td>
<td align="left">c++2a</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left">N/A</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
</tr>
<tr>
<td align="left"><a href="https://zh.cppreference.com/w/cpp/memory/new/destroying_delete_t" target="_blank" rel="noopener">std::destroying_delete</a></td>
<td align="left"><a href="https://wg21.link/P0722R3" target="_blank" rel="noopener">P0722R3</a></td>
<td align="left">c++2a</td>
<td align="left">9</td>
<td align="left"></td>
<td align="left"></td>
<td align="left">N/A</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
</tr>
<tr>
<td align="left"><a href="https://zh.cppreference.com/w/cpp/concepts" target="_blank" rel="noopener">概念库</a></td>
<td align="left"><a href="https://wg21.link/P0898R3" target="_blank" rel="noopener">P0898R3</a></td>
<td align="left">c++2a</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left">N/A</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
</tr>
<tr>
<td align="left"><a href="https://zh.cppreference.com/w/cpp/container/vector/erase2" target="_blank" rel="noopener">一致的容器擦除</a></td>
<td align="left"><a href="https://wg21.link/P1209R0" target="_blank" rel="noopener">P1209R0</a></td>
<td align="left">c++2a</td>
<td align="left">9</td>
<td align="left">8</td>
<td align="left"></td>
<td align="left">N/A</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
</tr>
<tr>
<td align="left">C++2a 功能特性</td>
<td align="left">提案</td>
<td align="left">版本</td>
<td align="left">GCC</td>
<td align="left">Clang</td>
<td align="left">MSVC</td>
<td align="left">EDG eccp</td>
<td align="left">Intel C++</td>
<td align="left">IBM XLC++</td>
<td align="left">Sun/Oracle C++</td>
<td align="left">Embarcadero C++ Builder</td>
<td align="left">Cray</td>
<td align="left">Portland Group (PGI)</td>
<td align="left"></td>
</tr>
</tbody></table>
<h2 id="C-17-功能特性"><a href="#C-17-功能特性" class="headerlink" title="C++17 功能特性"></a>C++17 功能特性</h2><table>
<thead>
<tr>
<th align="left">C++17 功能特性</th>
<th align="left">提案</th>
<th align="left">版本</th>
<th align="left">GCC</th>
<th align="left">Clang</th>
<th align="left">MSVC</th>
<th align="left">EDG eccp</th>
<th align="left">Intel C++</th>
<th align="left">IBM XLC++</th>
<th align="left">Sun/Oracle C++</th>
<th align="left">Embarcadero C++ Builder</th>
<th align="left">Cray</th>
<th align="left">Portland Group (PGI)</th>
<th align="left">[<a href="https://zh.cppreference.com/w/cpp/compiler_support#" target="_blank" rel="noopener">折叠</a>]</th>
</tr>
</thead>
<tbody><tr>
<td align="left">直接列表初始化的新 auto 规则</td>
<td align="left"><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n3922.html" target="_blank" rel="noopener">N3922</a></td>
<td align="left">c++17-lang</td>
<td align="left">5</td>
<td align="left">3.8</td>
<td align="left">19.0*</td>
<td align="left">4.10.1</td>
<td align="left">17.0</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left">17.7</td>
<td align="left"></td>
</tr>
<tr>
<td align="left">无消息的 <a href="https://zh.cppreference.com/w/cpp/language/static_assert" target="_blank" rel="noopener">static_assert</a></td>
<td align="left"><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n3928.pdf" target="_blank" rel="noopener">N3928</a></td>
<td align="left">c++17-lang</td>
<td align="left">6</td>
<td align="left">2.5</td>
<td align="left">19.10*</td>
<td align="left">4.12</td>
<td align="left">18.0</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left">17.7</td>
<td align="left"></td>
</tr>
<tr>
<td align="left">模板模板形参中的 <code>typename</code></td>
<td align="left"><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4051.html" target="_blank" rel="noopener">N4051</a></td>
<td align="left">c++17-lang</td>
<td align="left">5</td>
<td align="left">3.5</td>
<td align="left">19.0*</td>
<td align="left">4.10.1</td>
<td align="left">17.0</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left">17.7</td>
<td align="left"></td>
</tr>
<tr>
<td align="left">移除三标符</td>
<td align="left"><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4086.html" target="_blank" rel="noopener">N4086</a></td>
<td align="left">c++17-lang</td>
<td align="left">5</td>
<td align="left">3.5</td>
<td align="left">16.0*</td>
<td align="left">5.0</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
</tr>
<tr>
<td align="left">嵌套命名空间定义</td>
<td align="left"><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4230.html" target="_blank" rel="noopener">N4230</a></td>
<td align="left">c++17-lang</td>
<td align="left">6</td>
<td align="left">3.6</td>
<td align="left">19.0*</td>
<td align="left">4.12</td>
<td align="left">17.0</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left">17.7</td>
<td align="left"></td>
</tr>
<tr>
<td align="left">命名空间和枚举项的属性</td>
<td align="left"><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4266.html" target="_blank" rel="noopener">N4266</a></td>
<td align="left">c++17-lang</td>
<td align="left">4.9 (命名空间) / 6 (枚举项)</td>
<td align="left">3.6</td>
<td align="left">19.0*</td>
<td align="left">4.11</td>
<td align="left">17.0</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left">17.7</td>
<td align="left"></td>
</tr>
<tr>
<td align="left"><a href="https://zh.cppreference.com/w/cpp/language/character_literal" target="_blank" rel="noopener"><code>u8</code> 字符字面量</a></td>
<td align="left"><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4267.html" target="_blank" rel="noopener">N4267</a></td>
<td align="left">c++17-lang</td>
<td align="left">6</td>
<td align="left">3.6</td>
<td align="left">19.0*</td>
<td align="left">4.11</td>
<td align="left">17.0</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left">17.7</td>
<td align="left"></td>
</tr>
<tr>
<td align="left">允许所有非类型模板实参的常量求值</td>
<td align="left"><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4268.html" target="_blank" rel="noopener">N4268</a></td>
<td align="left">c++17-lang</td>
<td align="left">6</td>
<td align="left">3.6</td>
<td align="left">19.12*</td>
<td align="left">5.0</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
</tr>
<tr>
<td align="left"><a href="https://zh.cppreference.com/w/cpp/language/fold" target="_blank" rel="noopener">折叠表达式</a></td>
<td align="left"><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4295.html" target="_blank" rel="noopener">N4295</a></td>
<td align="left">c++17-lang</td>
<td align="left">6</td>
<td align="left">3.6</td>
<td align="left">19.12*</td>
<td align="left">4.14</td>
<td align="left">19.0</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left">18.1</td>
<td align="left"></td>
</tr>
<tr>
<td align="left">移除 register 关键字的已弃用用法</td>
<td align="left"><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/p0001r1.html" target="_blank" rel="noopener">P0001R1</a></td>
<td align="left">c++17-lang</td>
<td align="left">7</td>
<td align="left">3.8</td>
<td align="left">19.11*</td>
<td align="left">4.13</td>
<td align="left">18.0</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left">17.7</td>
<td align="left"></td>
</tr>
<tr>
<td align="left">移除已弃用的 operator++(bool)</td>
<td align="left"><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/p0002r1.html" target="_blank" rel="noopener">P0002R1</a></td>
<td align="left">c++17-lang</td>
<td align="left">7</td>
<td align="left">3.8</td>
<td align="left">19.11*</td>
<td align="left">4.13</td>
<td align="left">18.0</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left">17.7</td>
<td align="left"></td>
</tr>
<tr>
<td align="left">从 C++17 移除已弃用的异常规定</td>
<td align="left"><a href="http://wg21.link/p0003r5" target="_blank" rel="noopener">P0003R5</a></td>
<td align="left">c++17-lang</td>
<td align="left">7</td>
<td align="left">4</td>
<td align="left">19.10*</td>
<td align="left">4.14</td>
<td align="left">19.0</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
</tr>
<tr>
<td align="left">令异常规定为类型系统的一部分</td>
<td align="left"><a href="http://wg21.link/p0012r1" target="_blank" rel="noopener">P0012R1</a></td>
<td align="left">c++17-lang</td>
<td align="left">7</td>
<td align="left">4</td>
<td align="left">19.12*</td>
<td align="left">4.14</td>
<td align="left">19.0</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
</tr>
<tr>
<td align="left">有基类的类的聚合初始化</td>
<td align="left"><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/p0017r1.html" target="_blank" rel="noopener">P0017R1</a></td>
<td align="left">c++17-lang</td>
<td align="left">7</td>
<td align="left">3.9</td>
<td align="left">19.14*</td>
<td align="left">5.0</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
</tr>
<tr>
<td align="left"><code>*this</code> 的 lambda 捕获</td>
<td align="left"><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0018r3.html" target="_blank" rel="noopener">P0018R3</a></td>
<td align="left">c++17-lang</td>
<td align="left">7</td>
<td align="left">3.9</td>
<td align="left">19.11*</td>
<td align="left">4.14</td>
<td align="left">19.0</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left">18.1</td>
<td align="left"></td>
</tr>
<tr>
<td align="left">使用属性命名空间而不重复</td>
<td align="left"><a href="http://wg21.link/p0028r4" target="_blank" rel="noopener">P0028R4</a></td>
<td align="left">c++17-lang</td>
<td align="left">7</td>
<td align="left">3.9</td>
<td align="left">19.11*</td>
<td align="left">4.13</td>
<td align="left">18.0</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left">17.7</td>
<td align="left"></td>
</tr>
<tr>
<td align="left">过对齐数据的<a href="https://zh.cppreference.com/w/cpp/language/new" target="_blank" rel="noopener">动态内存分配</a></td>
<td align="left"><a href="http://wg21.link/p0035r4" target="_blank" rel="noopener">P0035R4</a></td>
<td align="left">c++17-lang</td>
<td align="left">7</td>
<td align="left">4</td>
<td align="left">19.12*</td>
<td align="left">4.14</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
</tr>
<tr>
<td align="left">一元折叠表达式和空形参包</td>
<td align="left"><a href="http://wg21.link/p0036r0" target="_blank" rel="noopener">P0036R0</a></td>
<td align="left">c++17-lang</td>
<td align="left">6</td>
<td align="left">3.9</td>
<td align="left">19.12*</td>
<td align="left">4.14</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
</tr>
<tr>
<td align="left">预处理器条件中的 <a href="https://zh.cppreference.com/w/cpp/preprocessor/include" target="_blank" rel="noopener">__has_include</a></td>
<td align="left"><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/p0061r1.html" target="_blank" rel="noopener">P0061R1</a></td>
<td align="left">c++17-lang</td>
<td align="left">5</td>
<td align="left">是</td>
<td align="left">19.11*</td>
<td align="left">4.13</td>
<td align="left">18.0</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left">17.7</td>
<td align="left"></td>
</tr>
<tr>
<td align="left"><a href="https://zh.cppreference.com/w/cpp/language/class_template_argument_deduction" target="_blank" rel="noopener">类模板实参推导</a></td>
<td align="left"><a href="http://wg21.link/p0091r3" target="_blank" rel="noopener">P0091R3</a></td>
<td align="left">c++17-lang</td>
<td align="left">7</td>
<td align="left">5</td>
<td align="left">19.14*</td>
<td align="left">5.0</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left">19.1</td>
<td align="left"></td>
</tr>
<tr>
<td align="left">具有 <code>auto</code> 类型的非类型模板形参</td>
<td align="left"><a href="http://wg21.link/p0127r2" target="_blank" rel="noopener">P0127R2</a></td>
<td align="left">c++17-lang</td>
<td align="left">7</td>
<td align="left">4</td>
<td align="left">19.14*</td>
<td align="left">5.0</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left">19.1</td>
<td align="left"></td>
</tr>
<tr>
<td align="left">有保证的<a href="https://zh.cppreference.com/w/cpp/language/copy_elision" target="_blank" rel="noopener">复制消除</a></td>
<td align="left"><a href="http://wg21.link/p0135r1" target="_blank" rel="noopener">P0135R1</a></td>
<td align="left">c++17-lang</td>
<td align="left">7</td>
<td align="left">4</td>
<td align="left">19.13*</td>
<td align="left">5.0</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left">19.1</td>
<td align="left"></td>
</tr>
<tr>
<td align="left">继承构造函数的新规定 (DR1941 等)</td>
<td align="left"><a href="http://wg21.link/p0136r1" target="_blank" rel="noopener">P0136R1</a></td>
<td align="left">c++17-lang</td>
<td align="left">7</td>
<td align="left">3.9</td>
<td align="left">19.14*</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
</tr>
<tr>
<td align="left">替换含引用成员的类对象</td>
<td align="left"><a href="http://wg21.link/p0137r1" target="_blank" rel="noopener">P0137R1</a></td>
<td align="left">c++17-lang</td>
<td align="left">7</td>
<td align="left">6</td>
<td align="left">19.14*</td>
<td align="left">5.0</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
</tr>
<tr>
<td align="left">枚举的直接列表初始化</td>
<td align="left"><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0138r2.pdf" target="_blank" rel="noopener">P0138R2</a></td>
<td align="left">c++17-lang</td>
<td align="left">7</td>
<td align="left">3.9</td>
<td align="left">19.11*</td>
<td align="left">4.14</td>
<td align="left">18.0</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
</tr>
<tr>
<td align="left">更严格的表达式求值顺序</td>
<td align="left"><a href="http://wg21.link/p0145r3" target="_blank" rel="noopener">P0145R3</a></td>
<td align="left">c++17-lang</td>
<td align="left">7</td>
<td align="left">4</td>
<td align="left">19.14*</td>
<td align="left">5.0</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
</tr>
<tr>
<td align="left">constexpr lambda 表达式</td>
<td align="left"><a href="http://wg21.link/p0170r1" target="_blank" rel="noopener">P0170R1</a></td>
<td align="left">c++17-lang</td>
<td align="left">7</td>
<td align="left">5</td>
<td align="left">19.11*</td>
<td align="left">4.14</td>
<td align="left">19.0</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left">18.1</td>
<td align="left"></td>
</tr>
<tr>
<td align="left">基于范围 for 的相异 begin 和 end 类型</td>
<td align="left"><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0184r0.html" target="_blank" rel="noopener">P0184R0</a></td>
<td align="left">c++17-lang</td>
<td align="left">6</td>
<td align="left">3.9</td>
<td align="left">19.10*</td>
<td align="left">4.12</td>
<td align="left">18.0</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left">17.7</td>
<td align="left"></td>
</tr>
<tr>
<td align="left"><code>[[fallthrough]]</code> 属性</td>
<td align="left"><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0188r1.pdf" target="_blank" rel="noopener">P0188R1</a></td>
<td align="left">c++17-lang</td>
<td align="left">7</td>
<td align="left">3.9</td>
<td align="left">19.10*</td>
<td align="left">4.13</td>
<td align="left">18.0</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left">17.7</td>
<td align="left"></td>
</tr>
<tr>
<td align="left"><code>[[nodiscard]]</code> 属性</td>
<td align="left"><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0189r1.pdf" target="_blank" rel="noopener">P0189R1</a></td>
<td align="left">c++17-lang</td>
<td align="left">7</td>
<td align="left">3.9</td>
<td align="left">19.11*</td>
<td align="left">4.13</td>
<td align="left">18.0</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left">17.7</td>
<td align="left"></td>
</tr>
<tr>
<td align="left">using 声明中的包展开</td>
<td align="left"><a href="http://wg21.link/p0195r2" target="_blank" rel="noopener">P0195R2</a></td>
<td align="left">c++17-lang</td>
<td align="left">7</td>
<td align="left">4</td>
<td align="left">19.14*</td>
<td align="left">5.0</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
</tr>
<tr>
<td align="left"><code>[[maybe_unused]]</code> 属性</td>
<td align="left"><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0212r1.pdf" target="_blank" rel="noopener">P0212R1</a></td>
<td align="left">c++17-lang</td>
<td align="left">7</td>
<td align="left">3.9</td>
<td align="left">19.11*</td>
<td align="left">4.13</td>
<td align="left">18.0</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left">17.7</td>
<td align="left"></td>
</tr>
<tr>
<td align="left">结构化绑定</td>
<td align="left"><a href="http://wg21.link/p0217r3" target="_blank" rel="noopener">P0217R3</a></td>
<td align="left">c++17-lang</td>
<td align="left">7</td>
<td align="left">4</td>
<td align="left">19.11*</td>
<td align="left">4.14</td>
<td align="left">19.0</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left">18.1</td>
<td align="left"></td>
</tr>
<tr>
<td align="left">十六进制浮点字面量</td>
<td align="left"><a href="http://wg21.link/p0245r1" target="_blank" rel="noopener">P0245R1</a></td>
<td align="left">c++17-lang</td>
<td align="left">3.0</td>
<td align="left">是</td>
<td align="left">19.11*</td>
<td align="left">4.13</td>
<td align="left">18.0</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left">17.7</td>
<td align="left"></td>
</tr>
<tr>
<td align="left">忽略未知属性</td>
<td align="left"><a href="http://wg21.link/p0283r2" target="_blank" rel="noopener">P0283R2</a></td>
<td align="left">c++17-lang</td>
<td align="left">是</td>
<td align="left">3.9</td>
<td align="left">19.11*</td>
<td align="left">4.13</td>
<td align="left">18.0</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left">17.7</td>
<td align="left"></td>
</tr>
<tr>
<td align="left"><a href="https://zh.cppreference.com/w/cpp/language/if" target="_blank" rel="noopener">constexpr if</a> 语句</td>
<td align="left"><a href="http://wg21.link/p0292r2" target="_blank" rel="noopener">P0292R2</a></td>
<td align="left">c++17-lang</td>
<td align="left">7</td>
<td align="left">3.9</td>
<td align="left">19.11*</td>
<td align="left">4.14</td>
<td align="left">19.0</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left">18.1</td>
<td align="left"></td>
</tr>
<tr>
<td align="left">if 和 switch 的初始化语句</td>
<td align="left"><a href="http://wg21.link/p0305r1" target="_blank" rel="noopener">P0305R1</a></td>
<td align="left">c++17-lang</td>
<td align="left">7</td>
<td align="left">3.9</td>
<td align="left">19.11*</td>
<td align="left">4.14</td>
<td align="left">18.0</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left">18.1</td>
<td align="left"></td>
</tr>
<tr>
<td align="left">内联变量</td>
<td align="left"><a href="http://wg21.link/p0386r2" target="_blank" rel="noopener">P0386R2</a></td>
<td align="left">c++17-lang</td>
<td align="left">7</td>
<td align="left">3.9*</td>
<td align="left">19.12*</td>
<td align="left">4.14</td>
<td align="left">19.0</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left">18.1</td>
<td align="left"></td>
</tr>
<tr>
<td align="left">DR ：模板模板实参的匹配排除了兼容的模板</td>
<td align="left"><a href="http://wg21.link/p0522r0" target="_blank" rel="noopener">P0522R0</a></td>
<td align="left">c++17-lang</td>
<td align="left">7</td>
<td align="left">4</td>
<td align="left">19.12*</td>
<td align="left">5.0</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
</tr>
<tr>
<td align="left"><a href="https://zh.cppreference.com/w/cpp/error/uncaught_exception" target="_blank" rel="noopener">std::uncaught_exceptions</a></td>
<td align="left"><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4259" target="_blank" rel="noopener">N4259</a></td>
<td align="left">c++17</td>
<td align="left">6</td>
<td align="left">3.7</td>
<td align="left">19.0*</td>
<td align="left">N/A</td>
<td align="left">N/A</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left">N/A</td>
<td align="left"></td>
</tr>
<tr>
<td align="left">改进 <a href="https://zh.cppreference.com/w/cpp/utility/pair" target="_blank" rel="noopener">std::pair</a> 和 <a href="https://zh.cppreference.com/w/cpp/utility/tuple" target="_blank" rel="noopener">std::tuple</a></td>
<td align="left"><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4387.html" target="_blank" rel="noopener">N4387</a></td>
<td align="left">c++17</td>
<td align="left">6</td>
<td align="left">4</td>
<td align="left">19.0*</td>
<td align="left">N/A</td>
<td align="left">N/A</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left">N/A</td>
<td align="left"></td>
</tr>
<tr>
<td align="left"><a href="https://zh.cppreference.com/w/cpp/utility/any" target="_blank" rel="noopener">std::any</a></td>
<td align="left"><a href="http://wg21.link/p0220r1" target="_blank" rel="noopener">P0220R1</a></td>
<td align="left">c++17</td>
<td align="left">7</td>
<td align="left">4</td>
<td align="left">19.10*</td>
<td align="left">N/A</td>
<td align="left">N/A</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left">N/A</td>
<td align="left"></td>
</tr>
<tr>
<td align="left"><a href="https://zh.cppreference.com/w/cpp/utility/variant" target="_blank" rel="noopener">std::variant</a></td>
<td align="left"><a href="http://wg21.link/p0088r3" target="_blank" rel="noopener">P0088R3</a></td>
<td align="left">c++17</td>
<td align="left">7</td>
<td align="left">4</td>
<td align="left">19.10*</td>
<td align="left">N/A</td>
<td align="left">N/A</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left">N/A</td>
<td align="left"></td>
</tr>
<tr>
<td align="left"><a href="https://zh.cppreference.com/w/cpp/utility/optional" target="_blank" rel="noopener">std::optional</a></td>
<td align="left"><a href="http://wg21.link/p0220r1" target="_blank" rel="noopener">P0220R1</a></td>
<td align="left">c++17</td>
<td align="left">7</td>
<td align="left">4</td>
<td align="left">19.10*</td>
<td align="left">N/A</td>
<td align="left">N/A</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left">N/A</td>
<td align="left"></td>
</tr>
<tr>
<td align="left"><a href="https://zh.cppreference.com/w/cpp/thread/shared_mutex" target="_blank" rel="noopener">std::shared_mutex</a> （无时限）</td>
<td align="left"><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4508.html" target="_blank" rel="noopener">N4508</a></td>
<td align="left">c++17</td>
<td align="left">6</td>
<td align="left">3.7</td>
<td align="left">19.0*</td>
<td align="left">N/A</td>
<td align="left">N/A</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left">N/A</td>
<td align="left"></td>
</tr>
<tr>
<td align="left"><a href="https://zh.cppreference.com/w/cpp/string/basic_string_view" target="_blank" rel="noopener">std::string_view</a></td>
<td align="left"><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n3921.html" target="_blank" rel="noopener">N3921</a></td>
<td align="left">c++17</td>
<td align="left">7</td>
<td align="left">4</td>
<td align="left">19.10*</td>
<td align="left">N/A</td>
<td align="left">N/A</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left">N/A</td>
<td align="left"></td>
</tr>
<tr>
<td align="left">并行 TS 的标准化</td>
<td align="left"><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0024r2.html" target="_blank" rel="noopener">P0024R2</a></td>
<td align="left">c++17</td>
<td align="left"></td>
<td align="left"></td>
<td align="left">19.14* (部分)</td>
<td align="left">N/A</td>
<td align="left">18.0*</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left">N/A</td>
<td align="left"></td>
</tr>
<tr>
<td align="left">C++17 应当指代 C11 而不是 C99</td>
<td align="left"><a href="http://wg21.link/P0063R3" target="_blank" rel="noopener">P0063R3</a></td>
<td align="left">c++17</td>
<td align="left">9</td>
<td align="left">7</td>
<td align="left">19.0* (部分)*</td>
<td align="left">N/A</td>
<td align="left">N/A</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left">N/A</td>
<td align="left"></td>
</tr>
<tr>
<td align="left">初等字符串转换</td>
<td align="left"><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0067r5.html" target="_blank" rel="noopener">P0067R5</a></td>
<td align="left">c++17</td>
<td align="left">8 (无浮点)</td>
<td align="left"></td>
<td align="left">19.14<em>(无浮点) 19.15</em></td>
<td align="left">N/A</td>
<td align="left">N/A</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left">N/A</td>
<td align="left"></td>
</tr>
<tr>
<td align="left">数学特殊函数</td>
<td align="left"><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0226r1.pdf" target="_blank" rel="noopener">P0226R1</a></td>
<td align="left">c++17</td>
<td align="left">7</td>
<td align="left"></td>
<td align="left">19.14*</td>
<td align="left">N/A</td>
<td align="left">N/A</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left">N/A</td>
<td align="left"></td>
</tr>
<tr>
<td align="left">接合 map 和 set</td>
<td align="left"><a href="http://wg21.link/p0083r3" target="_blank" rel="noopener">P0083R3</a></td>
<td align="left">c++17</td>
<td align="left">7</td>
<td align="left">8</td>
<td align="left">19.12*</td>
<td align="left">N/A</td>
<td align="left">N/A</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left">N/A</td>
<td align="left"></td>
</tr>
<tr>
<td align="left"><a href="https://zh.cppreference.com/w/cpp/thread/hardware_destructive_interference_size" target="_blank" rel="noopener">硬件干涉大小</a></td>
<td align="left"><a href="http://wg21.link/p0154r1" target="_blank" rel="noopener">P0154R1</a></td>
<td align="left">c++17</td>
<td align="left"></td>
<td align="left"></td>
<td align="left">19.11*</td>
<td align="left">N/A</td>
<td align="left">N/A</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left">N/A</td>
<td align="left"></td>
</tr>
<tr>
<td align="left"><a href="https://zh.cppreference.com/w/cpp/filesystem" target="_blank" rel="noopener">std::filesystem</a></td>
<td align="left"><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0218r1.html" target="_blank" rel="noopener">P0218R1</a></td>
<td align="left">c++17</td>
<td align="left">8</td>
<td align="left">7</td>
<td align="left">19.14*</td>
<td align="left">N/A</td>
<td align="left">N/A</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left">N/A</td>
<td align="left"></td>
</tr>
<tr>
<td align="left"><a href="https://zh.cppreference.com/w/cpp/types/byte" target="_blank" rel="noopener">std::byte</a></td>
<td align="left"><a href="http://wg21.link/p0298r3" target="_blank" rel="noopener">P0298R3</a></td>
<td align="left">c++17</td>
<td align="left">7</td>
<td align="left">5</td>
<td align="left">19.11*</td>
<td align="left">N/A</td>
<td align="left">N/A</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left">N/A</td>
<td align="left"></td>
</tr>
<tr>
<td align="left">C++17 功能特性</td>
<td align="left">提案</td>
<td align="left">版本</td>
<td align="left">GCC</td>
<td align="left">Clang</td>
<td align="left">MSVC</td>
<td align="left">EDG eccp</td>
<td align="left">Intel C++</td>
<td align="left">IBM XLC++</td>
<td align="left">Sun/Oracle C++</td>
<td align="left">Embarcadero C++ Builder</td>
<td align="left">Cray</td>
<td align="left">Portland Group (PGI)</td>
<td align="left"></td>
</tr>
</tbody></table>
<h2 id="C-14-功能特性"><a href="#C-14-功能特性" class="headerlink" title="C++14 功能特性"></a>C++14 功能特性</h2><table>
<thead>
<tr>
<th align="left">C++14 功能特性</th>
<th align="left">提案</th>
<th align="left">版本</th>
<th align="left">GCC</th>
<th align="left">Clang</th>
<th align="left">MSVC</th>
<th align="left">EDG eccp</th>
<th align="left">Intel C++</th>
<th align="left">IBM XLC++</th>
<th align="left">Sun/Oracle C++</th>
<th align="left">Embarcadero C++ Builder</th>
<th align="left">Cray</th>
<th align="left">Portland Group (PGI)</th>
<th align="left">[<a href="https://zh.cppreference.com/w/cpp/compiler_support#" target="_blank" rel="noopener">折叠</a>]</th>
</tr>
</thead>
<tbody><tr>
<td align="left">按语境转换的遣词调整</td>
<td align="left"><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3323.pdf" target="_blank" rel="noopener">N3323</a></td>
<td align="left">c++14-lang</td>
<td align="left">4.9</td>
<td align="left">3.4</td>
<td align="left">18.0*</td>
<td align="left">4.9</td>
<td align="left">16.0</td>
<td align="left">13.1.2*</td>
<td align="left">5.15</td>
<td align="left"></td>
<td align="left">8.6</td>
<td align="left">16.1</td>
<td align="left"></td>
</tr>
<tr>
<td align="left">二进制字面量</td>
<td align="left"><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3472.pdf" target="_blank" rel="noopener">N3472</a></td>
<td align="left">c++14-lang</td>
<td align="left">4.3/4.9</td>
<td align="left">2.9</td>
<td align="left">19.0*</td>
<td align="left">4.10</td>
<td align="left">11.0</td>
<td align="left">13.1.2*</td>
<td align="left">5.14</td>
<td align="left"></td>
<td align="left">8.6</td>
<td align="left">2015</td>
<td align="left"></td>
</tr>
<tr>
<td align="left">decltype(auto) ，普通函数的返回类型推导</td>
<td align="left"><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3638.html" target="_blank" rel="noopener">N3638</a></td>
<td align="left">c++14-lang</td>
<td align="left">4.8/4.9</td>
<td align="left">3.3/3.4</td>
<td align="left">19.0*</td>
<td align="left">4.9</td>
<td align="left">15.0</td>
<td align="left">13.1.2*</td>
<td align="left">5.15</td>
<td align="left"></td>
<td align="left">8.6</td>
<td align="left">16.1</td>
<td align="left"></td>
</tr>
<tr>
<td align="left">带初始化/泛化的 lambda 捕获 (init-capture)</td>
<td align="left"><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3648.html" target="_blank" rel="noopener">N3648</a></td>
<td align="left">c++14-lang</td>
<td align="left">4.5/4.9</td>
<td align="left">3.4</td>
<td align="left">19.0*</td>
<td align="left">4.10</td>
<td align="left">15.0</td>
<td align="left"></td>
<td align="left">5.15</td>
<td align="left"></td>
<td align="left">8.6</td>
<td align="left">16.1</td>
<td align="left"></td>
</tr>
<tr>
<td align="left">泛型（多态） lambda 表达式</td>
<td align="left"><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3649.html" target="_blank" rel="noopener">N3649</a></td>
<td align="left">c++14-lang</td>
<td align="left">4.9</td>
<td align="left">3.4</td>
<td align="left">19.0*</td>
<td align="left">4.10</td>
<td align="left">16.0</td>
<td align="left">13.1.2*</td>
<td align="left">5.15</td>
<td align="left"></td>
<td align="left">8.6</td>
<td align="left">16.1</td>
<td align="left"></td>
</tr>
<tr>
<td align="left">变量模板</td>
<td align="left"><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3651.pdf" target="_blank" rel="noopener">N3651</a></td>
<td align="left">c++14-lang</td>
<td align="left">5</td>
<td align="left">3.4</td>
<td align="left">19.0*</td>
<td align="left">4.11</td>
<td align="left">17.0</td>
<td align="left">13.1.2*</td>
<td align="left">5.15</td>
<td align="left"></td>
<td align="left">8.6</td>
<td align="left">17.4</td>
<td align="left"></td>
</tr>
<tr>
<td align="left">扩展的 constexpr</td>
<td align="left"><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3652.html" target="_blank" rel="noopener">N3652</a></td>
<td align="left">c++14-lang</td>
<td align="left">5</td>
<td align="left">3.4</td>
<td align="left">19.10*</td>
<td align="left">4.11</td>
<td align="left">17.0</td>
<td align="left">13.1.2*</td>
<td align="left">5.15</td>
<td align="left"></td>
<td align="left">8.6</td>
<td align="left">17.4</td>
<td align="left"></td>
</tr>
<tr>
<td align="left">成员初始化器与聚合体 (NSDMI)</td>
<td align="left"><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3653.html" target="_blank" rel="noopener">N3653</a></td>
<td align="left">c++14-lang</td>
<td align="left">5</td>
<td align="left">3.3</td>
<td align="left">19.10*</td>
<td align="left">4.9</td>
<td align="left">16.0</td>
<td align="left"></td>
<td align="left">5.14</td>
<td align="left"></td>
<td align="left">8.6</td>
<td align="left">16.1</td>
<td align="left"></td>
</tr>
<tr>
<td align="left">澄清内存分配（分配的免除/融合）</td>
<td align="left"><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3664.html" target="_blank" rel="noopener">N3664</a></td>
<td align="left">c++14-lang</td>
<td align="left">N/A</td>
<td align="left">3.4</td>
<td align="left">N/A</td>
<td align="left">N/A</td>
<td align="left"></td>
<td align="left"></td>
<td align="left">N/A</td>
<td align="left"></td>
<td align="left">8.6</td>
<td align="left">17.4</td>
<td align="left"></td>
</tr>
<tr>
<td align="left"><code>[[deprecated]]</code> 属性</td>
<td align="left"><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3760.html" target="_blank" rel="noopener">N3760</a></td>
<td align="left">c++14-lang</td>
<td align="left">4.9</td>
<td align="left">3.4</td>
<td align="left">19.0*</td>
<td align="left">4.9</td>
<td align="left">15.0* 16.0</td>
<td align="left">13.1.2*</td>
<td align="left">5.14</td>
<td align="left"></td>
<td align="left">8.6</td>
<td align="left">16.1</td>
<td align="left"></td>
</tr>
<tr>
<td align="left">具大小解分配</td>
<td align="left"><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3778.html" target="_blank" rel="noopener">N3778</a></td>
<td align="left">c++14-lang</td>
<td align="left">5</td>
<td align="left">3.4</td>
<td align="left">19.0*</td>
<td align="left">4.10.1</td>
<td align="left">17.0</td>
<td align="left"></td>
<td align="left">5.14</td>
<td align="left"></td>
<td align="left">8.6</td>
<td align="left">16.1</td>
<td align="left"></td>
</tr>
<tr>
<td align="left">单引号作为数位分隔符</td>
<td align="left"><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3781.pdf" target="_blank" rel="noopener">N3781</a></td>
<td align="left">c++14-lang</td>
<td align="left">4.9</td>
<td align="left">3.4</td>
<td align="left">19.0*</td>
<td align="left">4.10</td>
<td align="left">16.0</td>
<td align="left">13.1.2*</td>
<td align="left">5.14</td>
<td align="left"></td>
<td align="left">8.6</td>
<td align="left">2015</td>
<td align="left"></td>
</tr>
<tr>
<td align="left"><a href="https://zh.cppreference.com/w/cpp/types/result_of" target="_blank" rel="noopener">std::result_of</a> 与 SFINAE</td>
<td align="left"><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3462.html" target="_blank" rel="noopener">N3462</a></td>
<td align="left">c++14</td>
<td align="left">5</td>
<td align="left">是</td>
<td align="left">19.0*</td>
<td align="left">N/A</td>
<td align="left">N/A</td>
<td align="left"></td>
<td align="left">5.15</td>
<td align="left">是</td>
<td align="left">8.6</td>
<td align="left">N/A</td>
<td align="left"></td>
</tr>
<tr>
<td align="left"><a href="https://zh.cppreference.com/w/cpp/header/complex" target="_blank" rel="noopener"></a> 的 <code>constexpr</code></td>
<td align="left"><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2011/n3302.html" target="_blank" rel="noopener">N3302</a></td>
<td align="left">c++14</td>
<td align="left">5</td>
<td align="left">3.4</td>
<td align="left">19.0*</td>
<td align="left">N/A</td>
<td align="left">N/A</td>
<td align="left"></td>
<td align="left">5.15</td>
<td align="left"></td>
<td align="left">8.6</td>
<td align="left">N/A</td>
<td align="left"></td>
</tr>
<tr>
<td align="left"><a href="https://zh.cppreference.com/w/cpp/header/chrono" target="_blank" rel="noopener"></a> 的 <code>constexpr</code></td>
<td align="left"><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3469.html" target="_blank" rel="noopener">N3469</a></td>
<td align="left">c++14</td>
<td align="left">5</td>
<td align="left">3.4</td>
<td align="left">19.0*</td>
<td align="left">N/A</td>
<td align="left">N/A</td>
<td align="left"></td>
<td align="left">5.15</td>
<td align="left"></td>
<td align="left">8.6</td>
<td align="left">N/A</td>
<td align="left"></td>
</tr>
<tr>
<td align="left"><a href="https://zh.cppreference.com/w/cpp/header/array" target="_blank" rel="noopener"></a> 的 <code>constexpr</code></td>
<td align="left"><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3470.html" target="_blank" rel="noopener">N3470</a></td>
<td align="left">c++14</td>
<td align="left">5</td>
<td align="left">3.4</td>
<td align="left">19.0*</td>
<td align="left">N/A</td>
<td align="left">N/A</td>
<td align="left"></td>
<td align="left">5.15</td>
<td align="left"></td>
<td align="left">8.6</td>
<td align="left">N/A</td>
<td align="left"></td>
</tr>
<tr>
<td align="left"><a href="https://zh.cppreference.com/w/cpp/header/initializer_list" target="_blank" rel="noopener"></a> 、 <a href="https://zh.cppreference.com/w/cpp/header/utility" target="_blank" rel="noopener"></a> 和 <a href="https://zh.cppreference.com/w/cpp/header/tuple" target="_blank" rel="noopener"></a> 的 <code>constexpr</code></td>
<td align="left"><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3471.html" target="_blank" rel="noopener">N3471</a></td>
<td align="left">c++14</td>
<td align="left">5</td>
<td align="left">3.4</td>
<td align="left">19.0*</td>
<td align="left">N/A</td>
<td align="left">N/A</td>
<td align="left"></td>
<td align="left">5.15</td>
<td align="left"></td>
<td align="left">8.6</td>
<td align="left">N/A</td>
<td align="left"></td>
</tr>
<tr>
<td align="left">改进的 <a href="https://zh.cppreference.com/w/cpp/types/integral_constant" target="_blank" rel="noopener">std::integral_constant</a></td>
<td align="left"><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3545.pdf" target="_blank" rel="noopener">N3545</a></td>
<td align="left">c++14</td>
<td align="left">5</td>
<td align="left">3.4</td>
<td align="left">19.0*</td>
<td align="left">N/A</td>
<td align="left">N/A</td>
<td align="left"></td>
<td align="left">5.15</td>
<td align="left"></td>
<td align="left">8.6</td>
<td align="left">N/A</td>
<td align="left"></td>
</tr>
<tr>
<td align="left"><a href="https://zh.cppreference.com/w/cpp/header/chrono" target="_blank" rel="noopener"></a> 和 <a href="https://zh.cppreference.com/w/cpp/header/string" target="_blank" rel="noopener"></a> 的用户定义字面量</td>
<td align="left"><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3642.pdf" target="_blank" rel="noopener">N3642</a></td>
<td align="left">c++14</td>
<td align="left">5</td>
<td align="left">3.4</td>
<td align="left">19.0*</td>
<td align="left">N/A</td>
<td align="left">N/A</td>
<td align="left"></td>
<td align="left">5.15</td>
<td align="left"></td>
<td align="left">8.6</td>
<td align="left">N/A</td>
<td align="left"></td>
</tr>
<tr>
<td align="left"><a href="https://zh.cppreference.com/w/cpp/named_req/ForwardIterator#.E5.AD.A4.E7.AB.8B.E8.BF.AD.E4.BB.A3.E5.99.A8" target="_blank" rel="noopener">空向前迭代器</a></td>
<td align="left"><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3644.pdf" target="_blank" rel="noopener">N3644</a></td>
<td align="left">c++14</td>
<td align="left">5*</td>
<td align="left">3.4</td>
<td align="left">19.0*</td>
<td align="left">N/A</td>
<td align="left">N/A</td>
<td align="left"></td>
<td align="left">5.15</td>
<td align="left"></td>
<td align="left">8.6</td>
<td align="left">N/A</td>
<td align="left"></td>
</tr>
<tr>
<td align="left"><a href="https://zh.cppreference.com/w/cpp/io/manip/quoted" target="_blank" rel="noopener">std::quoted</a></td>
<td align="left"><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3654.html" target="_blank" rel="noopener">N3654</a></td>
<td align="left">c++14</td>
<td align="left">5</td>
<td align="left">3.4</td>
<td align="left">19.0*</td>
<td align="left">N/A</td>
<td align="left">N/A</td>
<td align="left"></td>
<td align="left">5.15</td>
<td align="left"></td>
<td align="left">8.6</td>
<td align="left">N/A</td>
<td align="left"></td>
</tr>
<tr>
<td align="left">异质关联查找</td>
<td align="left"><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3657.htm" target="_blank" rel="noopener">N3657</a></td>
<td align="left">c++14</td>
<td align="left">5</td>
<td align="left">3.4</td>
<td align="left">19.0*</td>
<td align="left">N/A</td>
<td align="left">N/A</td>
<td align="left"></td>
<td align="left">5.15</td>
<td align="left"></td>
<td align="left">8.6</td>
<td align="left">N/A</td>
<td align="left"></td>
</tr>
<tr>
<td align="left"><a href="https://zh.cppreference.com/w/cpp/utility/integer_sequence" target="_blank" rel="noopener">std::integer_sequence</a></td>
<td align="left"><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3658.html" target="_blank" rel="noopener">N3658</a></td>
<td align="left">c++14</td>
<td align="left">5</td>
<td align="left">3.4</td>
<td align="left">19.0*</td>
<td align="left">N/A</td>
<td align="left">N/A</td>
<td align="left"></td>
<td align="left">5.15</td>
<td align="left"></td>
<td align="left">8.6</td>
<td align="left">N/A</td>
<td align="left"></td>
</tr>
<tr>
<td align="left"><a href="https://zh.cppreference.com/w/cpp/thread/shared_timed_mutex" target="_blank" rel="noopener">std::shared_timed_mutex</a></td>
<td align="left"><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3659.html" target="_blank" rel="noopener">N3659</a></td>
<td align="left">c++14</td>
<td align="left">5</td>
<td align="left">3.4</td>
<td align="left">19.0*</td>
<td align="left">N/A</td>
<td align="left">N/A</td>
<td align="left"></td>
<td align="left">5.15</td>
<td align="left"></td>
<td align="left">8.6</td>
<td align="left">N/A</td>
<td align="left"></td>
</tr>
<tr>
<td align="left"><a href="https://zh.cppreference.com/w/cpp/utility/exchange" target="_blank" rel="noopener">std::exchange</a></td>
<td align="left"><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3668.html" target="_blank" rel="noopener">N3668</a></td>
<td align="left">c++14</td>
<td align="left">5</td>
<td align="left">3.4</td>
<td align="left">19.0*</td>
<td align="left">N/A</td>
<td align="left">N/A</td>
<td align="left"></td>
<td align="left">5.15</td>
<td align="left"></td>
<td align="left">8.6</td>
<td align="left">N/A</td>
<td align="left"></td>
</tr>
<tr>
<td align="left">修正无 <code>const</code> 的 <code>constexpr</code>成员函数</td>
<td align="left"><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3669.pdf" target="_blank" rel="noopener">N3669</a></td>
<td align="left">c++14</td>
<td align="left">5</td>
<td align="left">3.4</td>
<td align="left">19.0*</td>
<td align="left">N/A</td>
<td align="left">N/A</td>
<td align="left"></td>
<td align="left">5.15</td>
<td align="left"></td>
<td align="left">8.6</td>
<td align="left">N/A</td>
<td align="left"></td>
</tr>
<tr>
<td align="left"><a href="https://zh.cppreference.com/w/cpp/utility/pair/get" target="_blank" rel="noopener">std::get()</a></td>
<td align="left"><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3670.html" target="_blank" rel="noopener">N3670</a></td>
<td align="left">c++14</td>
<td align="left">5</td>
<td align="left">3.4</td>
<td align="left">19.0*</td>
<td align="left">N/A</td>
<td align="left">N/A</td>
<td align="left"></td>
<td align="left">5.15</td>
<td align="left"></td>
<td align="left">8.6</td>
<td align="left">N/A</td>
<td align="left"></td>
</tr>
<tr>
<td align="left">双范围的 <a href="https://zh.cppreference.com/w/cpp/algorithm/equal" target="_blank" rel="noopener">std::equal</a> 、 <a href="https://zh.cppreference.com/w/cpp/algorithm/is_permutation" target="_blank" rel="noopener">std::is_permutation</a> 、 <a href="https://zh.cppreference.com/w/cpp/algorithm/mismatch" target="_blank" rel="noopener">std::mismatch</a></td>
<td align="left"><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3671.html" target="_blank" rel="noopener">N3671</a></td>
<td align="left">c++14</td>
<td align="left">5</td>
<td align="left">3.4</td>
<td align="left">19.0*</td>
<td align="left">N/A</td>
<td align="left">N/A</td>
<td align="left"></td>
<td align="left">5.15</td>
<td align="left"></td>
<td align="left">8.6</td>
<td align="left">N/A</td>
<td align="left"></td>
</tr>
<tr>
<td align="left">C++14 功能特性</td>
<td align="left">提案</td>
<td align="left">版本</td>
<td align="left">GCC</td>
<td align="left">Clang</td>
<td align="left">MSVC</td>
<td align="left">EDG eccp</td>
<td align="left">Intel C++</td>
<td align="left">IBM XLC++</td>
<td align="left">Sun/Oracle C++</td>
<td align="left">Embarcadero C++ Builder</td>
<td align="left">Cray</td>
<td align="left">Portland Group (PGI)</td>
<td align="left"></td>
</tr>
</tbody></table>
<h2 id="C-11-功能特性"><a href="#C-11-功能特性" class="headerlink" title="C++11 功能特性"></a>C++11 功能特性</h2><table>
<thead>
<tr>
<th align="left">C++11 功能特性</th>
<th align="left">提案</th>
<th align="left">版本</th>
<th align="left">GCC</th>
<th align="left">Clang</th>
<th align="left">MSVC</th>
<th align="left">EDG eccp</th>
<th align="left">Intel C++</th>
<th align="left">IBM XLC++</th>
<th align="left">Sun/Oracle C++</th>
<th align="left">Embarcadero C++ Builder</th>
<th align="left">Cray</th>
<th align="left">Portland Group (PGI)</th>
<th align="left">HP aCC</th>
<th align="left">Digital Mars C++</th>
<th align="left">[<a href="https://zh.cppreference.com/w/cpp/compiler_support#" target="_blank" rel="noopener">折叠</a>]</th>
</tr>
</thead>
<tbody><tr>
<td align="left"><a href="https://zh.cppreference.com/w/cpp/language/alignas" target="_blank" rel="noopener">alignas</a></td>
<td align="left"><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2341.pdf" target="_blank" rel="noopener">N2341</a></td>
<td align="left">c++11</td>
<td align="left">4.8</td>
<td align="left">3.0</td>
<td align="left">19.0*</td>
<td align="left">4.8</td>
<td align="left">15.0</td>
<td align="left">13.1.2*</td>
<td align="left">5.13</td>
<td align="left">是</td>
<td align="left">8.6</td>
<td align="left">2015</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
</tr>
<tr>
<td align="left"><a href="https://zh.cppreference.com/w/cpp/language/alignof" target="_blank" rel="noopener">alignof</a></td>
<td align="left"><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2341.pdf" target="_blank" rel="noopener">N2341</a></td>
<td align="left">c++11</td>
<td align="left">4.5</td>
<td align="left">2.9</td>
<td align="left">19.0*</td>
<td align="left">4.8</td>
<td align="left">15.0</td>
<td align="left">13.1.2*</td>
<td align="left">5.13</td>
<td align="left">是</td>
<td align="left">8.4</td>
<td align="left">2015</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
</tr>
<tr>
<td align="left"><a href="https://zh.cppreference.com/w/cpp/atomic" target="_blank" rel="noopener">原子操作</a></td>
<td align="left"><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2427.html" target="_blank" rel="noopener">N2427</a></td>
<td align="left">c++11</td>
<td align="left">4.4</td>
<td align="left">3.1</td>
<td align="left">17.0*</td>
<td align="left">Yes</td>
<td align="left">13.0</td>
<td align="left">13.1.2*</td>
<td align="left">5.14</td>
<td align="left">是</td>
<td align="left">8.4</td>
<td align="left">2015</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
</tr>
<tr>
<td align="left"><a href="https://zh.cppreference.com/w/cpp/language/auto" target="_blank" rel="noopener">auto</a></td>
<td align="left"><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n1984.pdf" target="_blank" rel="noopener">N1984(v1.0)</a></td>
<td align="left">c++11</td>
<td align="left">4.4(v1.0)</td>
<td align="left">是</td>
<td align="left">16.0*</td>
<td align="left">3.9</td>
<td align="left">11.0(v0.9) 12.0(v1.0)</td>
<td align="left">11.1(v1.0)</td>
<td align="left">5.13</td>
<td align="left">是</td>
<td align="left">8.4</td>
<td align="left">2015</td>
<td align="left">A.06.25</td>
<td align="left"></td>
<td align="left"></td>
</tr>
<tr>
<td align="left">C99 预处理器</td>
<td align="left"><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2004/n1653.htm" target="_blank" rel="noopener">N1653</a></td>
<td align="left">c++11</td>
<td align="left">4.3</td>
<td align="left">是</td>
<td align="left">19.0* (部分：变参宏有漏洞)</td>
<td align="left">4.1</td>
<td align="left">11.1</td>
<td align="left">10.1</td>
<td align="left">5.9</td>
<td align="left">是</td>
<td align="left">8.4</td>
<td align="left">2015</td>
<td align="left">A.06.25</td>
<td align="left">是</td>
<td align="left"></td>
</tr>
<tr>
<td align="left"><a href="https://zh.cppreference.com/w/cpp/language/constexpr" target="_blank" rel="noopener">constexpr</a></td>
<td align="left"><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2235.pdf" target="_blank" rel="noopener">N2235</a></td>
<td align="left">c++11</td>
<td align="left">4.6</td>
<td align="left">3.1</td>
<td align="left">19.0* (部分)</td>
<td align="left">4.6</td>
<td align="left">13.0* 14.0</td>
<td align="left">12.1* 13.1</td>
<td align="left">5.13</td>
<td align="left">是</td>
<td align="left">8.4</td>
<td align="left">2015</td>
<td align="left">A.06.28</td>
<td align="left"></td>
<td align="left"></td>
</tr>
<tr>
<td align="left"><a href="https://zh.cppreference.com/w/cpp/language/decltype" target="_blank" rel="noopener">decltype</a></td>
<td align="left">v1.0: <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2343.pdf" target="_blank" rel="noopener">N2343</a>v1.1: <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2011/n3276.pdf" target="_blank" rel="noopener">N3276</a></td>
<td align="left">c++11</td>
<td align="left">4.3(v1.0) 4.8.1(v1.1)</td>
<td align="left">2.9</td>
<td align="left">16.0*</td>
<td align="left">4.2(v1.0) 4.8(v1.1)</td>
<td align="left">11.0(v1.0) 12.0(v1.1)</td>
<td align="left">11.1(v1.0)</td>
<td align="left">5.13</td>
<td align="left">是</td>
<td align="left">8.4</td>
<td align="left">2015</td>
<td align="left">A.06.25</td>
<td align="left">8.52(v1.0)</td>
<td align="left"></td>
</tr>
<tr>
<td align="left">预置和弃置的函数</td>
<td align="left"><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2346.htm" target="_blank" rel="noopener">N2346</a></td>
<td align="left">c++11</td>
<td align="left">4.4</td>
<td align="left">3.0</td>
<td align="left">18.0*</td>
<td align="left">4.1</td>
<td align="left">12.0</td>
<td align="left">13.1</td>
<td align="left">5.13</td>
<td align="left">是</td>
<td align="left">8.4</td>
<td align="left">2015</td>
<td align="left">A.06.25</td>
<td align="left"></td>
<td align="left"></td>
</tr>
<tr>
<td align="left"><a href="https://zh.cppreference.com/w/cpp/language/initializer_list#.E5.A7.94.E6.89.98.E6.9E.84.E9.80.A0.E5.87.BD.E6.95.B0" target="_blank" rel="noopener">委托构造函数</a></td>
<td align="left"><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n1986.pdf" target="_blank" rel="noopener">N1986</a></td>
<td align="left">c++11</td>
<td align="left">4.7</td>
<td align="left">3.0</td>
<td align="left">18.0*</td>
<td align="left">4.7</td>
<td align="left">14.0</td>
<td align="left">11.1</td>
<td align="left">5.13</td>
<td align="left">是</td>
<td align="left">8.4</td>
<td align="left">2015</td>
<td align="left">A.06.28</td>
<td align="left"></td>
<td align="left"></td>
</tr>
<tr>
<td align="left">显式转换运算符</td>
<td align="left"><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2437.pdf" target="_blank" rel="noopener">N2437</a></td>
<td align="left">c++11</td>
<td align="left">4.5</td>
<td align="left">3.0</td>
<td align="left">18.0*</td>
<td align="left">4.4</td>
<td align="left">13.0</td>
<td align="left">12.1</td>
<td align="left">5.13</td>
<td align="left">是</td>
<td align="left">8.4</td>
<td align="left">2015</td>
<td align="left">A.06.27</td>
<td align="left"></td>
<td align="left"></td>
</tr>
<tr>
<td align="left">扩展的 friend 声明</td>
<td align="left"><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1791.pdf" target="_blank" rel="noopener">N1791</a></td>
<td align="left">c++11</td>
<td align="left">4.7</td>
<td align="left">2.9</td>
<td align="left">16.0* (部分) 18.0*</td>
<td align="left">4.1</td>
<td align="left">11.1* 12.0</td>
<td align="left">11.1</td>
<td align="left">5.13</td>
<td align="left">是</td>
<td align="left">8.4</td>
<td align="left">2015</td>
<td align="left">A.06.25</td>
<td align="left"></td>
<td align="left"></td>
</tr>
<tr>
<td align="left">extern template</td>
<td align="left"><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n1987.htm" target="_blank" rel="noopener">N1987</a></td>
<td align="left">c++11</td>
<td align="left">3.3</td>
<td align="left">是</td>
<td align="left">12.0*</td>
<td align="left">3.9</td>
<td align="left">9.0</td>
<td align="left">11.1</td>
<td align="left">5.13</td>
<td align="left">是</td>
<td align="left">8.4</td>
<td align="left">2015</td>
<td align="left">A.06.25</td>
<td align="left"></td>
<td align="left"></td>
</tr>
<tr>
<td align="left">前置 enum 声明</td>
<td align="left"><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2764.pdf" target="_blank" rel="noopener">N2764</a></td>
<td align="left">c++11</td>
<td align="left">4.6</td>
<td align="left">3.1</td>
<td align="left">17.0*</td>
<td align="left">4.5</td>
<td align="left">11.1* 14.0</td>
<td align="left">12.1</td>
<td align="left">5.13</td>
<td align="left">是</td>
<td align="left">8.4</td>
<td align="left">2015</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
</tr>
<tr>
<td align="left">继承的构造函数</td>
<td align="left"><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2540.htm" target="_blank" rel="noopener">N2540</a></td>
<td align="left">c++11</td>
<td align="left">4.8</td>
<td align="left">3.3</td>
<td align="left">19.0*</td>
<td align="left">4.8</td>
<td align="left">15.0</td>
<td align="left">13.1.1*</td>
<td align="left">5.13</td>
<td align="left">是</td>
<td align="left">8.4</td>
<td align="left">2015</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
</tr>
<tr>
<td align="left">初始化器列表</td>
<td align="left"><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2672.htm" target="_blank" rel="noopener">N2672</a></td>
<td align="left">c++11</td>
<td align="left">4.4</td>
<td align="left">3.1</td>
<td align="left">18.0*</td>
<td align="left">4.5</td>
<td align="left">13.0* 14.0</td>
<td align="left">13.1.2*</td>
<td align="left">5.13</td>
<td align="left">是</td>
<td align="left">8.4</td>
<td align="left">2015</td>
<td align="left">A.06.28</td>
<td align="left"></td>
<td align="left"></td>
</tr>
<tr>
<td align="left"><a href="https://zh.cppreference.com/w/cpp/language/lambda" target="_blank" rel="noopener">Lambda 表达式</a></td>
<td align="left">v0.9: <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2550.pdf" target="_blank" rel="noopener">N2550</a>v1.0: <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2658.pdf" target="_blank" rel="noopener">N2658</a> v1.1: <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2009/n2927.pdf" target="_blank" rel="noopener">N2927</a></td>
<td align="left">c++11</td>
<td align="left">4.5(v1.1)</td>
<td align="left">3.1</td>
<td align="left">16.0<em>(v1.0) 17.0</em>(v1.1)</td>
<td align="left">4.1(v1.1)</td>
<td align="left">12.0(v1.1)</td>
<td align="left">13.1.2*</td>
<td align="left">5.13</td>
<td align="left">是</td>
<td align="left">8.4</td>
<td align="left">2015</td>
<td align="left">A.06.25</td>
<td align="left"></td>
<td align="left"></td>
</tr>
<tr>
<td align="left">局部及无名类型作为模板形参</td>
<td align="left"><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2657.htm" target="_blank" rel="noopener">N2657</a></td>
<td align="left">c++11</td>
<td align="left">4.5</td>
<td align="left">2.9</td>
<td align="left">16.0*</td>
<td align="left">4.2</td>
<td align="left">12.0</td>
<td align="left">13.1.2*</td>
<td align="left">5.13</td>
<td align="left">是</td>
<td align="left">8.4</td>
<td align="left">2015</td>
<td align="left">A.06.27</td>
<td align="left"></td>
<td align="left"></td>
</tr>
<tr>
<td align="left">long long</td>
<td align="left"><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1811.pdf" target="_blank" rel="noopener">N1811</a></td>
<td align="left">c++11</td>
<td align="left">是</td>
<td align="left">是</td>
<td align="left">14.0*</td>
<td align="left">是</td>
<td align="left">是</td>
<td align="left">是</td>
<td align="left">是</td>
<td align="left">是</td>
<td align="left">8.4</td>
<td align="left">2015</td>
<td align="left">是</td>
<td align="left">是</td>
<td align="left"></td>
</tr>
<tr>
<td align="left">内联命名空间</td>
<td align="left"><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2535.htm" target="_blank" rel="noopener">N2535</a></td>
<td align="left">c++11</td>
<td align="left">4.4</td>
<td align="left">2.9</td>
<td align="left">19.0*</td>
<td align="left">4.5</td>
<td align="left">14.0</td>
<td align="left">11.1</td>
<td align="left">5.13</td>
<td align="left">是</td>
<td align="left">8.4</td>
<td align="left">2015</td>
<td align="left">A.06.28</td>
<td align="left"></td>
<td align="left"></td>
</tr>
<tr>
<td align="left">新字符类型</td>
<td align="left"><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2249.html" target="_blank" rel="noopener">N2249</a></td>
<td align="left">c++11</td>
<td align="left">4.4</td>
<td align="left">2.9</td>
<td align="left">19.0*</td>
<td align="left">4.4</td>
<td align="left">12.1* 14.0</td>
<td align="left">13.1.1*</td>
<td align="left">5.13</td>
<td align="left">是</td>
<td align="left">8.4</td>
<td align="left">2015</td>
<td align="left">A.06.27</td>
<td align="left">8.52</td>
<td align="left"></td>
</tr>
<tr>
<td align="left">尾随的函数返回类型</td>
<td align="left"><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2541.htm" target="_blank" rel="noopener">N2541</a></td>
<td align="left">c++11</td>
<td align="left">4.4</td>
<td align="left">2.9</td>
<td align="left">16.0*</td>
<td align="left">4.1</td>
<td align="left">12.0</td>
<td align="left">12.1</td>
<td align="left">5.13</td>
<td align="left">是</td>
<td align="left">8.4</td>
<td align="left">2015</td>
<td align="left">A.06.27</td>
<td align="left"></td>
<td align="left"></td>
</tr>
<tr>
<td align="left"><a href="https://zh.cppreference.com/w/cpp/language/nullptr" target="_blank" rel="noopener">nullptr</a></td>
<td align="left"><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2431.pdf" target="_blank" rel="noopener">N2431</a></td>
<td align="left">c++11</td>
<td align="left">4.6</td>
<td align="left">2.9</td>
<td align="left">16.0*</td>
<td align="left">4.2</td>
<td align="left">12.1</td>
<td align="left">13.1</td>
<td align="left">5.13</td>
<td align="left">是</td>
<td align="left">8.4</td>
<td align="left">2015</td>
<td align="left">A.06.27</td>
<td align="left">8.52</td>
<td align="left"></td>
</tr>
<tr>
<td align="left">Unicode 字符串字面量</td>
<td align="left"><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2442.htm" target="_blank" rel="noopener">N2442</a></td>
<td align="left">c++11</td>
<td align="left">4.4</td>
<td align="left">3.0</td>
<td align="left">19.0*</td>
<td align="left">4.7</td>
<td align="left">11.0*</td>
<td align="left">10.1* 13.1.1*</td>
<td align="left">5.7</td>
<td align="left">是</td>
<td align="left">8.4</td>
<td align="left">2015</td>
<td align="left">A.06.28</td>
<td align="left">8.52</td>
<td align="left"></td>
</tr>
<tr>
<td align="left">原始字符串字面量</td>
<td align="left"><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2442.htm" target="_blank" rel="noopener">N2442</a></td>
<td align="left">c++11</td>
<td align="left">4.5</td>
<td align="left">是</td>
<td align="left">18.0*</td>
<td align="left">4.7</td>
<td align="left">14.0</td>
<td align="left">13.1.1*</td>
<td align="left">5.13</td>
<td align="left">是</td>
<td align="left">8.4</td>
<td align="left">2015</td>
<td align="left">A.06.28</td>
<td align="left">8.52</td>
<td align="left"></td>
</tr>
<tr>
<td align="left">用户定义字面量</td>
<td align="left"><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2765.pdf" target="_blank" rel="noopener">N2765</a></td>
<td align="left">c++11</td>
<td align="left">4.7</td>
<td align="left">3.1</td>
<td align="left">19.0*</td>
<td align="left">4.8</td>
<td align="left">15.0</td>
<td align="left">13.1.2*</td>
<td align="left">5.14</td>
<td align="left">是</td>
<td align="left">8.4</td>
<td align="left">2015</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
</tr>
<tr>
<td align="left">右角括号</td>
<td align="left"><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1757.html" target="_blank" rel="noopener">N1757</a></td>
<td align="left">c++11</td>
<td align="left">4.3</td>
<td align="left">是</td>
<td align="left">14.0*</td>
<td align="left">4.1</td>
<td align="left">11.0</td>
<td align="left">12.1</td>
<td align="left">5.13</td>
<td align="left">是</td>
<td align="left">8.4</td>
<td align="left">2015</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
</tr>
<tr>
<td align="left">右值引用</td>
<td align="left">v1.0: <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n2118.html" target="_blank" rel="noopener">N2118</a>v2.0: <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2009/n2844.html" target="_blank" rel="noopener">N2844</a> v2.1: <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1138" target="_blank" rel="noopener">N2844+</a> v3.0: <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2010/n3053.html" target="_blank" rel="noopener">N3053</a></td>
<td align="left">c++11</td>
<td align="left">4.3(v1.0) 4.5(v2.1) 4.6(v3.0)</td>
<td align="left">是</td>
<td align="left">16.0<em>(v2.0) 17.0</em>(v2.1) 19.0*(v3.0)</td>
<td align="left">4.5(v3.0)</td>
<td align="left">11.1(v1.0) 12.0(v2.0) 14.0(v3.0)</td>
<td align="left">12.1(v2.1)</td>
<td align="left">5.13</td>
<td align="left">是</td>
<td align="left">8.4</td>
<td align="left">2015</td>
<td align="left">A.06.25</td>
<td align="left"></td>
<td align="left"></td>
</tr>
<tr>
<td align="left"><a href="https://zh.cppreference.com/w/cpp/language/static_assert" target="_blank" rel="noopener">static_assert</a></td>
<td align="left"><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2004/n1720.html" target="_blank" rel="noopener">N1720</a></td>
<td align="left">c++11</td>
<td align="left">4.3</td>
<td align="left">2.9</td>
<td align="left">16.0*</td>
<td align="left">4.1</td>
<td align="left">11.0</td>
<td align="left">11.1</td>
<td align="left">5.13</td>
<td align="left">是</td>
<td align="left">8.4</td>
<td align="left">2015</td>
<td align="left">A.06.25</td>
<td align="left">8.52</td>
<td align="left"></td>
</tr>
<tr>
<td align="left"><a href="https://zh.cppreference.com/w/cpp/language/enum#.E6.9C.89.E4.BD.9C.E7.94.A8.E5.9F.9F.E6.9E.9A.E4.B8.BE" target="_blank" rel="noopener">强类型 enum</a></td>
<td align="left"><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2347.pdf" target="_blank" rel="noopener">N2347</a></td>
<td align="left">c++11</td>
<td align="left">4.4</td>
<td align="left">2.9</td>
<td align="left">17.0*</td>
<td align="left">4.0</td>
<td align="left">13.0</td>
<td align="left">12.1</td>
<td align="left">5.13</td>
<td align="left">是</td>
<td align="left">8.4</td>
<td align="left">2015</td>
<td align="left">A.06.25</td>
<td align="left"></td>
<td align="left"></td>
</tr>
<tr>
<td align="left">模板别名</td>
<td align="left"><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2258.pdf" target="_blank" rel="noopener">N2258</a></td>
<td align="left">c++11</td>
<td align="left">4.7</td>
<td align="left">3.0</td>
<td align="left">18.0*</td>
<td align="left">4.2</td>
<td align="left">12.1</td>
<td align="left">13.1.1*</td>
<td align="left">5.13</td>
<td align="left">是</td>
<td align="left">8.4</td>
<td align="left">2015</td>
<td align="left">A.06.27</td>
<td align="left"></td>
<td align="left"></td>
</tr>
<tr>
<td align="left">线程局域存储</td>
<td align="left"><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2659.htm" target="_blank" rel="noopener">N2659</a></td>
<td align="left">c++11</td>
<td align="left">4.4* 4.8</td>
<td align="left">3.3* 3.3</td>
<td align="left">16.0* (部分) 19.0*</td>
<td align="left">4.8</td>
<td align="left">11.1* 15.0*</td>
<td align="left">10.1* 13.1.2*</td>
<td align="left">5.9*</td>
<td align="left">是</td>
<td align="left">8.4</td>
<td align="left">2015</td>
<td align="left"></td>
<td align="left">8.52*</td>
<td align="left"></td>
</tr>
<tr>
<td align="left">无限制的联合体</td>
<td align="left"><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2544.pdf" target="_blank" rel="noopener">N2544</a></td>
<td align="left">c++11</td>
<td align="left">4.6</td>
<td align="left">3.0</td>
<td align="left">19.0*</td>
<td align="left">4.6</td>
<td align="left">14.0*</td>
<td align="left">13.1.2*</td>
<td align="left">5.13</td>
<td align="left">是</td>
<td align="left">8.4</td>
<td align="left">2015</td>
<td align="left">A.06.28</td>
<td align="left"></td>
<td align="left"></td>
</tr>
<tr>
<td align="left">类型特征</td>
<td align="left"><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1836.pdf" target="_blank" rel="noopener">N1836</a></td>
<td align="left">c++11</td>
<td align="left">4.3</td>
<td align="left">3.0</td>
<td align="left">14.0*</td>
<td align="left">4.0</td>
<td align="left">10.0</td>
<td align="left">13.1.3</td>
<td align="left">5.13</td>
<td align="left">是</td>
<td align="left">8.4</td>
<td align="left">2015</td>
<td align="left">6.16</td>
<td align="left"></td>
<td align="left"></td>
</tr>
<tr>
<td align="left">变参模板</td>
<td align="left">v0.9: <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2242.pdf" target="_blank" rel="noopener">N2242</a>v1.0: <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2555.pdf" target="_blank" rel="noopener">N2555</a></td>
<td align="left">c++11</td>
<td align="left">4.3(v0.9) 4.4(v1.0)</td>
<td align="left">2.9(v1.0)</td>
<td align="left">18.0*</td>
<td align="left">4.3(v0.9) 4.3(v1.0)</td>
<td align="left">12.1(v1.0)</td>
<td align="left">11.1(v0.9)</td>
<td align="left">5.13</td>
<td align="left">是</td>
<td align="left">8.4</td>
<td align="left">2015</td>
<td align="left">A.06.27</td>
<td align="left"></td>
<td align="left"></td>
</tr>
<tr>
<td align="left">范围 for 循环</td>
<td align="left"><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2009/n2930.html" target="_blank" rel="noopener">N2930</a></td>
<td align="left">c++11</td>
<td align="left">4.6</td>
<td align="left">3.0</td>
<td align="left">17.0*</td>
<td align="left">4.5</td>
<td align="left">13.0</td>
<td align="left">13.1.2*</td>
<td align="left">5.13</td>
<td align="left">是</td>
<td align="left">8.4</td>
<td align="left">2015</td>
<td align="left">A.06.28</td>
<td align="left"></td>
<td align="left"></td>
</tr>
<tr>
<td align="left"><a href="https://zh.cppreference.com/w/cpp/language/override" target="_blank" rel="noopener">override</a> 与 <a href="https://zh.cppreference.com/w/cpp/language/final" target="_blank" rel="noopener">final</a></td>
<td align="left">v0.8: <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2009/n2928.htm" target="_blank" rel="noopener">N2928</a>v0.9: <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2010/n3206.htm" target="_blank" rel="noopener">N3206</a> v1.0: <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2011/n3272.htm" target="_blank" rel="noopener">N3272</a></td>
<td align="left">c++11</td>
<td align="left">4.7</td>
<td align="left">2.9</td>
<td align="left">14.0* (部分) 17.0*</td>
<td align="left">4.8(v1.0)</td>
<td align="left">12.0(v0.8) 14.0(v1.0)</td>
<td align="left">13.1.1*</td>
<td align="left">5.13</td>
<td align="left">是</td>
<td align="left">8.4</td>
<td align="left">2015</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
</tr>
<tr>
<td align="left">属性</td>
<td align="left"><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2761.pdf" target="_blank" rel="noopener">N2761</a></td>
<td align="left">c++11</td>
<td align="left">4.8</td>
<td align="left">3.3</td>
<td align="left">19.0*</td>
<td align="left">4.2</td>
<td align="left">12.1</td>
<td align="left">13.1.1*</td>
<td align="left">5.13</td>
<td align="left">是</td>
<td align="left">8.4</td>
<td align="left">2015</td>
<td align="left">A.06.27</td>
<td align="left"></td>
<td align="left"></td>
</tr>
<tr>
<td align="left">引用限定符</td>
<td align="left"><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2439.htm" target="_blank" rel="noopener">N2439</a></td>
<td align="left">c++11</td>
<td align="left">4.8.1</td>
<td align="left">2.9</td>
<td align="left">19.0*</td>
<td align="left">4.7</td>
<td align="left">14.0</td>
<td align="left">13.1.2*</td>
<td align="left">5.13</td>
<td align="left">是</td>
<td align="left">8.4</td>
<td align="left">2015</td>
<td align="left">A.06.28</td>
<td align="left"></td>
<td align="left"></td>
</tr>
<tr>
<td align="left">非静态数据成员初始化器</td>
<td align="left"><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2756.htm" target="_blank" rel="noopener">N2756</a></td>
<td align="left">c++11</td>
<td align="left">4.7</td>
<td align="left">3.0</td>
<td align="left">18.0*</td>
<td align="left">4.6</td>
<td align="left">14.0</td>
<td align="left">13.1.2*</td>
<td align="left">5.13</td>
<td align="left">是</td>
<td align="left">8.4</td>
<td align="left">2015</td>
<td align="left">A.06.28</td>
<td align="left"></td>
<td align="left"></td>
</tr>
<tr>
<td align="left">有并发的动态初始化及析构（<a href="https://zh.cppreference.com/w/cpp/language/storage_duration#.E9.9D.99.E6.80.81.E5.B1.80.E9.83.A8.E5.8F.98.E9.87.8F" target="_blank" rel="noopener">魔法静态变量</a>）</td>
<td align="left"><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2660.htm" target="_blank" rel="noopener">N2660</a></td>
<td align="left">c++11</td>
<td align="left">4.3</td>
<td align="left">2.9</td>
<td align="left">19.0*</td>
<td align="left">是</td>
<td align="left">11.1*</td>
<td align="left">13.1.2*</td>
<td align="left">5.13</td>
<td align="left">是</td>
<td align="left">8.4</td>
<td align="left">2015</td>
<td align="left">A.06.25</td>
<td align="left"></td>
<td align="left"></td>
</tr>
<tr>
<td align="left"><a href="https://zh.cppreference.com/w/cpp/language/noexcept_spec" target="_blank" rel="noopener">noexcept</a></td>
<td align="left"><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2010/n3050.html" target="_blank" rel="noopener">N3050</a></td>
<td align="left">c++11</td>
<td align="left">4.6</td>
<td align="left">3.0</td>
<td align="left">19.0*</td>
<td align="left">4.5</td>
<td align="left">14.0</td>
<td align="left">13.1.1*</td>
<td align="left">5.13</td>
<td align="left">是</td>
<td align="left">8.4</td>
<td align="left">2015</td>
<td align="left">A.06.28</td>
<td align="left"></td>
<td align="left"></td>
</tr>
<tr>
<td align="left">垃圾收集与基于可达性的泄漏检测</td>
<td align="left"><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2670.htm" target="_blank" rel="noopener">N2670</a></td>
<td align="left">c++11</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
</tr>
<tr>
<td align="left">垃圾收集与基于可达性的泄漏检测（<a href="https://zh.cppreference.com/w/cpp/memory#.E5.9E.83.E5.9C.BE.E6.94.B6.E9.9B.86.E5.99.A8.E6.94.AF.E6.8C.81" target="_blank" rel="noopener">库支持</a>）</td>
<td align="left"><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2670.htm" target="_blank" rel="noopener">N2670</a></td>
<td align="left">c++11</td>
<td align="left">6 (无操作)</td>
<td align="left">3.4 (无操作)</td>
<td align="left">19.0* (无操作)</td>
<td align="left">N/A</td>
<td align="left">N/A</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<td align="left">N/A</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
</tr>
<tr>
<td align="left"><a href="https://zh.cppreference.com/w/cpp/io/manip" target="_blank" rel="noopener">金额、时间及十六进制浮点 I/O 操纵符</a></td>
<td align="left">时间： <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n2071.html" target="_blank" rel="noopener">N2071</a>金额： <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n2072.html" target="_blank" rel="noopener">N2072</a></td>
<td align="left">c++11</td>
<td align="left">5</td>
<td align="left">3.8</td>
<td align="left">19.0*</td>
<td align="left">N/A</td>
<td align="left">N/A</td>
<td align="left"></td>
<td align="left">5.15</td>
<td align="left"></td>
<td align="left"></td>
<td align="left">N/A</td>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
</tr>
<tr>
<td align="left">C++11 功能特性</td>
<td align="left">提案</td>
<td align="left">版本</td>
<td align="left">GCC</td>
<td align="left">Clang</td>
<td align="left">MSVC</td>
<td align="left">EDG eccp</td>
<td align="left">Intel C++</td>
<td align="left">IBM XLC++</td>
<td align="left">Sun/Oracle C++</td>
<td align="left">Embarcadero C++ Builder</td>
<td align="left">Cray</td>
<td align="left">Portland Group (PGI)</td>
<td align="left">HP aCC</td>
<td align="left">Digital Mars C++</td>
<td align="left"></td>
</tr>
</tbody></table>

    </div>

    
    
    
        
      

      <footer class="post-footer">
          
            
          
          <div class="post-tags">
            
              <a href="/tags/C-11/" rel="tag"># C++11</a>
            
          </div>
        

        

          <div class="post-nav">
            <div class="post-nav-next post-nav-item">
              
                <a href="/2019/05/30/C++编程指南/" rel="next" title="C++编程指南">
                  <i class="fa fa-chevron-left"></i> C++编程指南
                </a>
              
            </div>

            <span class="post-nav-divider"></span>

            <div class="post-nav-prev post-nav-item">
              
                <a href="/2019/06/05/设计模式/" rel="prev" title="设计模式">
                  设计模式 <i class="fa fa-chevron-right"></i>
                </a>
              
            </div>
          </div>
        
      </footer>
    
  </div>
  
  
  
  </article>

  </div>


          </div>
          

        </div>
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    <div class="sidebar-inner">
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap">
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview-wrap">
            站点概览
          </li>
        </ul>
      

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-overview">

          <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
  <p class="site-author-name" itemprop="name">XuQi</p>
  <div class="site-description motion-element" itemprop="description"></div>
</div>
  <nav class="site-state motion-element">
      <div class="site-state-item site-state-posts">
        
          <a href="/archives/">
        
          <span class="site-state-item-count">44</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
    
      
      
      <div class="site-state-item site-state-tags">
        
        
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
        <span class="site-state-item-count">30</span>
        <span class="site-state-item-name">标签</span>
        
      </div>
    
  </nav>



        </div>
      </div>
      <!--noindex-->
        <div class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
            
            
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#C-11-amp-C-14-amp-C-17-常用新特性总结"><span class="nav-number">1.</span> <span class="nav-text">C++11 &amp; C++14 &amp; C++17 常用新特性总结</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#GCC编译器（从编译器GCC4-8-X的版本完全支持）"><span class="nav-number">1.1.</span> <span class="nav-text">GCC编译器（从编译器GCC4.8.X的版本完全支持）</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#C-11新特性"><span class="nav-number">1.2.</span> <span class="nav-text">C+11新特性</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#nullptr"><span class="nav-number">1.2.1.</span> <span class="nav-text">nullptr</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#类型推导-auto和decltype"><span class="nav-number">1.2.2.</span> <span class="nav-text">类型推导 auto和decltype</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#auto"><span class="nav-number">1.2.2.1.</span> <span class="nav-text">auto</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#decltype"><span class="nav-number">1.2.2.2.</span> <span class="nav-text">decltype</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#拖尾类型返回"><span class="nav-number">1.2.2.3.</span> <span class="nav-text">拖尾类型返回</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#区间迭代"><span class="nav-number">1.2.3.</span> <span class="nav-text">区间迭代</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#初始化列表"><span class="nav-number">1.2.4.</span> <span class="nav-text">初始化列表</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#模板增强"><span class="nav-number">1.2.5.</span> <span class="nav-text">模板增强</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#尖括号-“-gt-”"><span class="nav-number">1.2.5.1.</span> <span class="nav-text">尖括号 “&gt;”</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#构造函数"><span class="nav-number">1.2.6.</span> <span class="nav-text">构造函数</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#委托构造"><span class="nav-number">1.2.6.1.</span> <span class="nav-text">委托构造</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#继承构造"><span class="nav-number">1.2.6.2.</span> <span class="nav-text">继承构造</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#Lambda-表达式"><span class="nav-number">1.2.7.</span> <span class="nav-text">Lambda 表达式</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#新增容器"><span class="nav-number">1.2.8.</span> <span class="nav-text">新增容器</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#std-array"><span class="nav-number">1.2.8.1.</span> <span class="nav-text">std::array</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#std-forward-list"><span class="nav-number">1.2.8.2.</span> <span class="nav-text">std::forward_list</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#无序容器"><span class="nav-number">1.2.8.3.</span> <span class="nav-text">无序容器</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#元组-std-tuple"><span class="nav-number">1.2.8.4.</span> <span class="nav-text">元组 std::tuple</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#正则表达式"><span class="nav-number">1.2.9.</span> <span class="nav-text">正则表达式</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#语言级线程支持"><span class="nav-number">1.2.10.</span> <span class="nav-text">语言级线程支持</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#右值引用-amp-amp"><span class="nav-number">1.2.11.</span> <span class="nav-text">右值引用&amp;&amp;</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#std-move"><span class="nav-number">1.2.11.1.</span> <span class="nav-text">std::move</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#命名对象使用-std-move右值引用"><span class="nav-number">1.2.11.2.</span> <span class="nav-text">命名对象使用 std::move右值引用</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#使用右值引用精确传递"><span class="nav-number">1.2.11.3.</span> <span class="nav-text">使用右值引用精确传递</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#智能指针"><span class="nav-number">1.2.11.4.</span> <span class="nav-text">智能指针</span></a><ol class="nav-child"><li class="nav-item nav-level-5"><a class="nav-link" href="#shared-ptr"><span class="nav-number">1.2.11.4.1.</span> <span class="nav-text">shared_ptr</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#unique-ptr"><span class="nav-number">1.2.11.4.2.</span> <span class="nav-text">unique_ptr</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#weak-ptr"><span class="nav-number">1.2.11.4.3.</span> <span class="nav-text">weak_ptr</span></a></li></ol></li><li class="nav-item nav-level-4"><a class="nav-link" href="#std-function"><span class="nav-number">1.2.11.5.</span> <span class="nav-text">std::function</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#std-bind"><span class="nav-number">1.2.11.6.</span> <span class="nav-text">std::bind</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#std-forward"><span class="nav-number">1.2.11.7.</span> <span class="nav-text">std::forward</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#delete"><span class="nav-number">1.2.11.8.</span> <span class="nav-text">delete</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#enable-shared-from-this"><span class="nav-number">1.2.11.9.</span> <span class="nav-text">enable_shared_from_this</span></a><ol class="nav-child"><li class="nav-item nav-level-5"><a class="nav-link" href="#定义"><span class="nav-number">1.2.11.9.1.</span> <span class="nav-text">定义</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#使用场合"><span class="nav-number">1.2.11.9.2.</span> <span class="nav-text">使用场合</span></a></li></ol></li><li class="nav-item nav-level-4"><a class="nav-link" href="#mutable"><span class="nav-number">1.2.11.10.</span> <span class="nav-text">mutable</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#using各种用法"><span class="nav-number">1.2.11.11.</span> <span class="nav-text">using各种用法</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#参考信息"><span class="nav-number">1.2.12.</span> <span class="nav-text">参考信息</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#C-17-功能特性"><span class="nav-number">1.3.</span> <span class="nav-text">C++17 功能特性</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#C-14-功能特性"><span class="nav-number">1.4.</span> <span class="nav-text">C++14 功能特性</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#C-11-功能特性"><span class="nav-number">1.5.</span> <span class="nav-text">C++11 功能特性</span></a></li></ol></li></ol></div>
            

          </div>
        </div>
      <!--/noindex-->
      

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright">&copy; <span itemprop="copyrightYear">2019</span>
  <span class="with-love" id="animate">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">XuQi</span>
</div>
  <div class="powered-by">由 <a href="https://hexo.io" class="theme-link" rel="noopener" target="_blank">Hexo</a> 强力驱动 v3.9.0</div>
  <span class="post-meta-divider">|</span>
  <div class="theme-info">主题 – <a href="https://theme-next.org" class="theme-link" rel="noopener" target="_blank">NexT.Muse</a> v7.3.0</div>

        








        
      </div>
    </footer>
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
      </div>

    

  </div>

  
  <script src="/lib/jquery/index.js?v=3.4.1"></script>
  <script src="/lib/velocity/velocity.min.js?v=1.2.1"></script>
  <script src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>

<script src="/js/utils.js?v=7.3.0"></script>
  <script src="/js/motion.js?v=7.3.0"></script>


  <script src="/js/schemes/muse.js?v=7.3.0"></script>


<script src="/js/next-boot.js?v=7.3.0"></script>




  




























  

  

  


  
  <script src="/js/scrollspy.js?v=7.3.0"></script>
<script src="/js/post-details.js?v=7.3.0"></script>


</body>
</html>
